wxTreeListCtrl updates: fixed wrapping of GetSelections and made
keyboard navigation work like MSW's native tree when on MSW. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@21403 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -4665,18 +4665,29 @@ static PyObject *_wrap_wxTreeListCtrl_GetSelection(PyObject *self, PyObject *arg
|
|||||||
return _resultobj;
|
return _resultobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define wxTreeListCtrl_GetSelections(_swigobj,_swigarg0) (_swigobj->GetSelections(_swigarg0))
|
static PyObject * wxPyTreeListCtrl_GetSelections(wxPyTreeListCtrl *self) {
|
||||||
|
wxPyBeginBlockThreads();
|
||||||
|
PyObject* rval = PyList_New(0);
|
||||||
|
wxArrayTreeItemIds array;
|
||||||
|
size_t num, x;
|
||||||
|
num = self->GetSelections(array);
|
||||||
|
for (x=0; x < num; x++) {
|
||||||
|
wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
|
||||||
|
PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), TRUE);
|
||||||
|
PyList_Append(rval, item);
|
||||||
|
}
|
||||||
|
wxPyEndBlockThreads();
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
static PyObject *_wrap_wxTreeListCtrl_GetSelections(PyObject *self, PyObject *args, PyObject *kwargs) {
|
static PyObject *_wrap_wxTreeListCtrl_GetSelections(PyObject *self, PyObject *args, PyObject *kwargs) {
|
||||||
PyObject * _resultobj;
|
PyObject * _resultobj;
|
||||||
size_t _result;
|
PyObject * _result;
|
||||||
wxPyTreeListCtrl * _arg0;
|
wxPyTreeListCtrl * _arg0;
|
||||||
wxArrayTreeItemIds * _arg1;
|
|
||||||
PyObject * _argo0 = 0;
|
PyObject * _argo0 = 0;
|
||||||
PyObject * _argo1 = 0;
|
char *_kwnames[] = { "self", NULL };
|
||||||
char *_kwnames[] = { "self","arg2", NULL };
|
|
||||||
|
|
||||||
self = self;
|
self = self;
|
||||||
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxTreeListCtrl_GetSelections",_kwnames,&_argo0,&_argo1))
|
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxTreeListCtrl_GetSelections",_kwnames,&_argo0))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (_argo0) {
|
if (_argo0) {
|
||||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||||
@@ -4685,19 +4696,15 @@ static PyObject *_wrap_wxTreeListCtrl_GetSelections(PyObject *self, PyObject *ar
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_argo1) {
|
|
||||||
if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxArrayTreeItemIds_p")) {
|
|
||||||
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxTreeListCtrl_GetSelections. Expected _wxArrayTreeItemIds_p.");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
PyThreadState* __tstate = wxPyBeginAllowThreads();
|
PyThreadState* __tstate = wxPyBeginAllowThreads();
|
||||||
_result = (size_t )wxTreeListCtrl_GetSelections(_arg0,*_arg1);
|
_result = (PyObject *)wxPyTreeListCtrl_GetSelections(_arg0);
|
||||||
|
|
||||||
wxPyEndAllowThreads(__tstate);
|
wxPyEndAllowThreads(__tstate);
|
||||||
if (PyErr_Occurred()) return NULL;
|
if (PyErr_Occurred()) return NULL;
|
||||||
} _resultobj = Py_BuildValue("i",_result);
|
}{
|
||||||
|
_resultobj = _result;
|
||||||
|
}
|
||||||
return _resultobj;
|
return _resultobj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -719,7 +719,24 @@ public:
|
|||||||
wxTreeItemId GetSelection() const;
|
wxTreeItemId GetSelection() const;
|
||||||
|
|
||||||
// get the items currently selected, return the number of such item
|
// get the items currently selected, return the number of such item
|
||||||
size_t GetSelections(wxArrayTreeItemIds&) const;
|
//size_t GetSelections(wxArrayTreeItemIds&) const;
|
||||||
|
%addmethods {
|
||||||
|
PyObject* GetSelections() {
|
||||||
|
wxPyBeginBlockThreads();
|
||||||
|
PyObject* rval = PyList_New(0);
|
||||||
|
wxArrayTreeItemIds array;
|
||||||
|
size_t num, x;
|
||||||
|
num = self->GetSelections(array);
|
||||||
|
for (x=0; x < num; x++) {
|
||||||
|
wxTreeItemId *tii = new wxTreeItemId(array.Item(x));
|
||||||
|
PyObject* item = wxPyConstructObject((void*)tii, wxT("wxTreeItemId"), TRUE);
|
||||||
|
PyList_Append(rval, item);
|
||||||
|
}
|
||||||
|
wxPyEndBlockThreads();
|
||||||
|
return rval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// get the parent of this item (may return NULL if root)
|
// get the parent of this item (may return NULL if root)
|
||||||
%name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
|
%name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
|
||||||
|
@@ -3530,18 +3530,19 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
event.ControlDown(),
|
event.ControlDown(),
|
||||||
is_multiple, extended_select, unselect_others);
|
is_multiple, extended_select, unselect_others);
|
||||||
|
|
||||||
// + : Expand
|
// + : Expand (not on Win32)
|
||||||
// - : Collaspe
|
// - : Collaspe (not on Win32)
|
||||||
// * : Expand all/Collapse all
|
// * : Expand all/Collapse all
|
||||||
// ' ' | return : activate
|
// ' ' | return : activate
|
||||||
// up : go up (not last children!)
|
// up : go up (not last children!)
|
||||||
// down : go down
|
// down : go down
|
||||||
// left : go to parent
|
// left : go to parent (or collapse on Win32)
|
||||||
// right : open if parent and go next
|
// right : open if parent and go next (or expand on Win32)
|
||||||
// home : go to root
|
// home : go to root
|
||||||
// end : go to last item without opening parents
|
// end : go to last item without opening parents
|
||||||
switch (event.KeyCode())
|
switch (event.KeyCode())
|
||||||
{
|
{
|
||||||
|
#ifndef __WXMSW__ // mimic the standard win32 tree ctrl
|
||||||
case '+':
|
case '+':
|
||||||
case WXK_ADD:
|
case WXK_ADD:
|
||||||
if (m_current->HasPlus() && !IsExpanded(m_current))
|
if (m_current->HasPlus() && !IsExpanded(m_current))
|
||||||
@@ -3549,6 +3550,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
Expand(m_current);
|
Expand(m_current);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
case '*':
|
case '*':
|
||||||
case WXK_MULTIPLY:
|
case WXK_MULTIPLY:
|
||||||
@@ -3560,6 +3562,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
}
|
}
|
||||||
//else: fall through to Collapse() it
|
//else: fall through to Collapse() it
|
||||||
|
|
||||||
|
#ifndef __WXMSW__ // mimic the standard wxTreeCtrl behaviour
|
||||||
case '-':
|
case '-':
|
||||||
case WXK_SUBTRACT:
|
case WXK_SUBTRACT:
|
||||||
if (IsExpanded(m_current))
|
if (IsExpanded(m_current))
|
||||||
@@ -3567,6 +3570,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
Collapse(m_current);
|
Collapse(m_current);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
case ' ':
|
case ' ':
|
||||||
case WXK_RETURN:
|
case WXK_RETURN:
|
||||||
@@ -3626,6 +3630,13 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
|
|
||||||
// left arrow goes to the parent
|
// left arrow goes to the parent
|
||||||
case WXK_LEFT:
|
case WXK_LEFT:
|
||||||
|
#if defined(__WXMSW__) // mimic the standard win32 tree ctrl
|
||||||
|
if (IsExpanded(m_current))
|
||||||
|
{
|
||||||
|
Collapse(m_current);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // __WXMSW__
|
||||||
{
|
{
|
||||||
wxTreeItemId prev = GetParent( m_current );
|
wxTreeItemId prev = GetParent( m_current );
|
||||||
if ((prev == GetRootItem()) && HasFlag(wxTR_HIDE_ROOT))
|
if ((prev == GetRootItem()) && HasFlag(wxTR_HIDE_ROOT))
|
||||||
@@ -3642,6 +3653,14 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case WXK_RIGHT:
|
case WXK_RIGHT:
|
||||||
|
#if defined(__WXMSW__) // mimic the standard win32 tree ctrl
|
||||||
|
if (m_current->HasPlus() && !IsExpanded(m_current))
|
||||||
|
{
|
||||||
|
Expand(m_current);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif // __WXMSW__
|
||||||
|
|
||||||
// this works the same as the down arrow except that we
|
// this works the same as the down arrow except that we
|
||||||
// also expand the item if it wasn't expanded yet
|
// also expand the item if it wasn't expanded yet
|
||||||
Expand(m_current);
|
Expand(m_current);
|
||||||
|
Reference in New Issue
Block a user