From 419c299ae50da93b157c707cb983520611f9d31e Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Fri, 18 May 2001 02:32:22 +0000 Subject: [PATCH] Fixed wxPoint.__cmp__ and a few others git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@10201 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- wxPython/CHANGES.txt | 2 ++ wxPython/src/misc.i | 21 ++++++++++----- wxPython/src/msw/misc.cpp | 54 ++++++++++++++++++++++++++++++++++----- wxPython/src/msw/misc.py | 3 +++ wxPython/src/msw/wx.cpp | 2 ++ wxPython/src/msw/wx.py | 2 ++ 6 files changed, 72 insertions(+), 12 deletions(-) diff --git a/wxPython/CHANGES.txt b/wxPython/CHANGES.txt index 866eafe865..041246aa1e 100644 --- a/wxPython/CHANGES.txt +++ b/wxPython/CHANGES.txt @@ -107,6 +107,8 @@ specific. It could have been added long ago but OOR required it. Finally added wxPyLineShape.GetLineControlPoints, which has been on my list for a while. The above OOR modification made this easier. +Fixed the __cmp__ methods for wxPoiunt and others. + 2.2.6 diff --git a/wxPython/src/misc.i b/wxPython/src/misc.i index db74ff8614..ddf5e91558 100644 --- a/wxPython/src/misc.i +++ b/wxPython/src/misc.i @@ -75,6 +75,12 @@ public: PyTuple_SET_ITEM(tup, 1, PyInt_FromLong(self->y)); return tup; } + + int __cmp__(const wxSize* sz) { + if (! sz) return 1; + if (*self == *sz) return 0; + return -1; + } } %pragma(python) addtoclass = " @@ -122,8 +128,9 @@ public: } int __cmp__(const wxRealPoint* p) { - if (! p) return 0; - return *self == *p; + if (! p) return 1; + if (*self == *p) return 0; + return -1; } } %pragma(python) addtoclass = " @@ -169,8 +176,9 @@ public: } int __cmp__(const wxPoint* p) { - if (! p) return 0; - return *self == *p; + if (! p) return 1; + if (*self == *p) return 0; + return -1; } } %pragma(python) addtoclass = " @@ -237,8 +245,9 @@ public: } int __cmp__(const wxRect* rect) { - if (! rect) return 0; - return *self == *rect; + if (! rect) return 1; + if (*self == *rect) return 0; + return -1; } } diff --git a/wxPython/src/msw/misc.cpp b/wxPython/src/msw/misc.cpp index 1d5157532f..a222d306e3 100644 --- a/wxPython/src/msw/misc.cpp +++ b/wxPython/src/msw/misc.cpp @@ -1325,6 +1325,44 @@ static PyObject *_wrap_wxSize_asTuple(PyObject *self, PyObject *args, PyObject * return _resultobj; } +static int wxSize___cmp__(wxSize *self,const wxSize * sz) { + if (! sz) return 1; + if (*self == *sz) return 0; + return -1; + } +static PyObject *_wrap_wxSize___cmp__(PyObject *self, PyObject *args, PyObject *kwargs) { + PyObject * _resultobj; + int _result; + wxSize * _arg0; + wxSize * _arg1; + wxSize temp; + PyObject * _obj0 = 0; + wxSize temp0; + PyObject * _obj1 = 0; + char *_kwnames[] = { "self","sz", NULL }; + + self = self; + if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxSize___cmp__",_kwnames,&_obj0,&_obj1)) + return NULL; +{ + _arg0 = &temp; + if (! wxSize_helper(_obj0, &_arg0)) + return NULL; +} +{ + _arg1 = &temp0; + if (! wxSize_helper(_obj1, &_arg1)) + return NULL; +} +{ + wxPy_BEGIN_ALLOW_THREADS; + _result = (int )wxSize___cmp__(_arg0,_arg1); + + wxPy_END_ALLOW_THREADS; +} _resultobj = Py_BuildValue("i",_result); + return _resultobj; +} + #define wxRealPoint_x_set(_swigobj,_swigval) (_swigobj->x = _swigval,_swigval) static PyObject *_wrap_wxRealPoint_x_set(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -1627,8 +1665,9 @@ static PyObject *_wrap_wxRealPoint___sub__(PyObject *self, PyObject *args, PyObj } static int wxRealPoint___cmp__(wxRealPoint *self,const wxRealPoint * p) { - if (! p) return 0; - return *self == *p; + if (! p) return 1; + if (*self == *p) return 0; + return -1; } static PyObject *_wrap_wxRealPoint___cmp__(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -1965,8 +2004,9 @@ static PyObject *_wrap_wxPoint___sub__(PyObject *self, PyObject *args, PyObject } static int wxPoint___cmp__(wxPoint *self,const wxPoint * p) { - if (! p) return 0; - return *self == *p; + if (! p) return 1; + if (*self == *p) return 0; + return -1; } static PyObject *_wrap_wxPoint___cmp__(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -2879,8 +2919,9 @@ static PyObject *_wrap_wxRect___add__(PyObject *self, PyObject *args, PyObject * } static int wxRect___cmp__(wxRect *self,const wxRect * rect) { - if (! rect) return 0; - return *self == *rect; + if (! rect) return 1; + if (*self == *rect) return 0; + return -1; } static PyObject *_wrap_wxRect___cmp__(PyObject *self, PyObject *args, PyObject *kwargs) { PyObject * _resultobj; @@ -3990,6 +4031,7 @@ static PyMethodDef misccMethods[] = { { "wxRealPoint_y_set", (PyCFunction) _wrap_wxRealPoint_y_set, METH_VARARGS | METH_KEYWORDS }, { "wxRealPoint_x_get", (PyCFunction) _wrap_wxRealPoint_x_get, METH_VARARGS | METH_KEYWORDS }, { "wxRealPoint_x_set", (PyCFunction) _wrap_wxRealPoint_x_set, METH_VARARGS | METH_KEYWORDS }, + { "wxSize___cmp__", (PyCFunction) _wrap_wxSize___cmp__, METH_VARARGS | METH_KEYWORDS }, { "wxSize_asTuple", (PyCFunction) _wrap_wxSize_asTuple, METH_VARARGS | METH_KEYWORDS }, { "wxSize_SetHeight", (PyCFunction) _wrap_wxSize_SetHeight, METH_VARARGS | METH_KEYWORDS }, { "wxSize_SetWidth", (PyCFunction) _wrap_wxSize_SetWidth, METH_VARARGS | METH_KEYWORDS }, diff --git a/wxPython/src/msw/misc.py b/wxPython/src/msw/misc.py index de639e834b..13e92a9c84 100644 --- a/wxPython/src/msw/misc.py +++ b/wxPython/src/msw/misc.py @@ -50,6 +50,9 @@ class wxSizePtr : def asTuple(self, *_args, **_kwargs): val = apply(miscc.wxSize_asTuple,(self,) + _args, _kwargs) return val + def __cmp__(self, *_args, **_kwargs): + val = apply(miscc.wxSize___cmp__,(self,) + _args, _kwargs) + return val def __setattr__(self,name,value): if name == "x" : miscc.wxSize_x_set(self,value) diff --git a/wxPython/src/msw/wx.cpp b/wxPython/src/msw/wx.cpp index 5cbda48fa6..35cb245944 100644 --- a/wxPython/src/msw/wx.cpp +++ b/wxPython/src/msw/wx.cpp @@ -3000,6 +3000,8 @@ SWIGEXPORT(void) initwxc() { PyDict_SetItemString(d,"wxEVT_MEASURE_ITEM", PyInt_FromLong((long) wxEVT_MEASURE_ITEM)); PyDict_SetItemString(d,"wxEVT_COMPARE_ITEM", PyInt_FromLong((long) wxEVT_COMPARE_ITEM)); PyDict_SetItemString(d,"wxEVT_INIT_DIALOG", PyInt_FromLong((long) wxEVT_INIT_DIALOG)); + PyDict_SetItemString(d,"wxEVT_HELP", PyInt_FromLong((long) wxEVT_HELP)); + PyDict_SetItemString(d,"wxEVT_DETAILED_HELP", PyInt_FromLong((long) wxEVT_DETAILED_HELP)); PyDict_SetItemString(d,"wxEVT_IDLE", PyInt_FromLong((long) wxEVT_IDLE)); PyDict_SetItemString(d,"wxEVT_UPDATE_UI", PyInt_FromLong((long) wxEVT_UPDATE_UI)); PyDict_SetItemString(d,"wxEVT_COMMAND_LEFT_CLICK", PyInt_FromLong((long) wxEVT_COMMAND_LEFT_CLICK)); diff --git a/wxPython/src/msw/wx.py b/wxPython/src/msw/wx.py index 7a135d91c7..cb72f6a5fa 100644 --- a/wxPython/src/msw/wx.py +++ b/wxPython/src/msw/wx.py @@ -818,6 +818,8 @@ wxEVT_DRAW_ITEM = wxc.wxEVT_DRAW_ITEM wxEVT_MEASURE_ITEM = wxc.wxEVT_MEASURE_ITEM wxEVT_COMPARE_ITEM = wxc.wxEVT_COMPARE_ITEM wxEVT_INIT_DIALOG = wxc.wxEVT_INIT_DIALOG +wxEVT_HELP = wxc.wxEVT_HELP +wxEVT_DETAILED_HELP = wxc.wxEVT_DETAILED_HELP wxEVT_IDLE = wxc.wxEVT_IDLE wxEVT_UPDATE_UI = wxc.wxEVT_UPDATE_UI wxEVT_COMMAND_LEFT_CLICK = wxc.wxEVT_COMMAND_LEFT_CLICK