Added wrapper for wxListCtrl.SortItems. Added column sorting to the

demo to show how to use it.

Other fixes and updates.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6324 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2000-02-28 04:05:41 +00:00
parent 984ef9dce7
commit dcd386834a
11 changed files with 165 additions and 20 deletions

View File

@@ -111,6 +111,24 @@ static char* wxStringErrorMsg = "string type is required for parameter";
extern wxValidator wxPyDefaultValidator;
int wxCALLBACK wxPyTreeCtrl_SortItems(long item1, long item2, long funcPtr) {
int retval = 0;
PyObject* func = (PyObject*)funcPtr;
bool doSave = wxPyRestoreThread();
PyObject* args = Py_BuildValue("(ii)", item1, item2);
PyObject* result = PyEval_CallObject(func, args);
Py_DECREF(args);
if (result) {
retval = PyInt_AsLong(result);
Py_DECREF(result);
}
wxPySaveThread(doSave);
return retval;
}
class wxPyTreeItemData : public wxTreeItemData {
public:
wxPyTreeItemData(PyObject* obj = NULL) {
@@ -2986,6 +3004,43 @@ static PyObject *_wrap_wxListCtrl_SetWindowStyleFlag(PyObject *self, PyObject *a
return _resultobj;
}
static bool wxListCtrl_SortItems(wxListCtrl *self,PyObject * func) {
if (!PyCallable_Check(func))
return FALSE;
return self->SortItems(wxPyTreeCtrl_SortItems, (long)func);
}
static PyObject *_wrap_wxListCtrl_SortItems(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
bool _result;
wxListCtrl * _arg0;
PyObject * _arg1;
PyObject * _argo0 = 0;
PyObject * _obj1 = 0;
char *_kwnames[] = { "self","func", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxListCtrl_SortItems",_kwnames,&_argo0,&_obj1))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxListCtrl_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxListCtrl_SortItems. Expected _wxListCtrl_p.");
return NULL;
}
}
{
_arg1 = _obj1;
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (bool )wxListCtrl_SortItems(_arg0,_arg1);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
#define new_wxTreeItemId() (new wxTreeItemId())
static PyObject *_wrap_new_wxTreeItemId(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
@@ -6095,6 +6150,7 @@ static PyMethodDef controls2cMethods[] = {
{ "wxTreeItemId_IsOk", (PyCFunction) _wrap_wxTreeItemId_IsOk, METH_VARARGS | METH_KEYWORDS },
{ "delete_wxTreeItemId", (PyCFunction) _wrap_delete_wxTreeItemId, METH_VARARGS | METH_KEYWORDS },
{ "new_wxTreeItemId", (PyCFunction) _wrap_new_wxTreeItemId, METH_VARARGS | METH_KEYWORDS },
{ "wxListCtrl_SortItems", (PyCFunction) _wrap_wxListCtrl_SortItems, METH_VARARGS | METH_KEYWORDS },
{ "wxListCtrl_SetWindowStyleFlag", (PyCFunction) _wrap_wxListCtrl_SetWindowStyleFlag, METH_VARARGS | METH_KEYWORDS },
{ "wxListCtrl_SetSingleStyle", (PyCFunction) _wrap_wxListCtrl_SetSingleStyle, METH_VARARGS | METH_KEYWORDS },
{ "wxListCtrl_SetItemText", (PyCFunction) _wrap_wxListCtrl_SetItemText, METH_VARARGS | METH_KEYWORDS },

View File

@@ -300,6 +300,9 @@ class wxListCtrlPtr(wxControlPtr):
def SetWindowStyleFlag(self, *_args, **_kwargs):
val = apply(controls2c.wxListCtrl_SetWindowStyleFlag,(self,) + _args, _kwargs)
return val
def SortItems(self, *_args, **_kwargs):
val = apply(controls2c.wxListCtrl_SortItems,(self,) + _args, _kwargs)
return val
def __repr__(self):
return "<C wxListCtrl instance at %s>" % (self.this,)
class wxListCtrl(wxListCtrlPtr):

View File

@@ -7530,7 +7530,7 @@ static PyObject *_wrap_new_wxImageList(PyObject *self, PyObject *args, PyObject
wxImageList * _result;
int _arg0;
int _arg1;
int _arg2 = (int ) FALSE;
int _arg2 = (int ) TRUE;
int _arg3 = (int ) 1;
char *_kwnames[] = { "width","height","mask","initialCount", NULL };
char _ptemp[128];