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;
|
||||
}
|
||||
|
||||
#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) {
|
||||
PyObject * _resultobj;
|
||||
size_t _result;
|
||||
PyObject * _result;
|
||||
wxPyTreeListCtrl * _arg0;
|
||||
wxArrayTreeItemIds * _arg1;
|
||||
PyObject * _argo0 = 0;
|
||||
PyObject * _argo1 = 0;
|
||||
char *_kwnames[] = { "self","arg2", NULL };
|
||||
char *_kwnames[] = { "self", NULL };
|
||||
|
||||
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;
|
||||
if (_argo0) {
|
||||
if (_argo0 == Py_None) { _arg0 = NULL; }
|
||||
@@ -4685,19 +4696,15 @@ static PyObject *_wrap_wxTreeListCtrl_GetSelections(PyObject *self, PyObject *ar
|
||||
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();
|
||||
_result = (size_t )wxTreeListCtrl_GetSelections(_arg0,*_arg1);
|
||||
_result = (PyObject *)wxPyTreeListCtrl_GetSelections(_arg0);
|
||||
|
||||
wxPyEndAllowThreads(__tstate);
|
||||
if (PyErr_Occurred()) return NULL;
|
||||
} _resultobj = Py_BuildValue("i",_result);
|
||||
}{
|
||||
_resultobj = _result;
|
||||
}
|
||||
return _resultobj;
|
||||
}
|
||||
|
||||
|
@@ -719,7 +719,24 @@ public:
|
||||
wxTreeItemId GetSelection() const;
|
||||
|
||||
// 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)
|
||||
%name(GetItemParent)wxTreeItemId GetParent(const wxTreeItemId& item) const;
|
||||
|
@@ -3530,18 +3530,19 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
||||
event.ControlDown(),
|
||||
is_multiple, extended_select, unselect_others);
|
||||
|
||||
// + : Expand
|
||||
// - : Collaspe
|
||||
// + : Expand (not on Win32)
|
||||
// - : Collaspe (not on Win32)
|
||||
// * : Expand all/Collapse all
|
||||
// ' ' | return : activate
|
||||
// up : go up (not last children!)
|
||||
// down : go down
|
||||
// left : go to parent
|
||||
// right : open if parent and go next
|
||||
// left : go to parent (or collapse on Win32)
|
||||
// right : open if parent and go next (or expand on Win32)
|
||||
// home : go to root
|
||||
// end : go to last item without opening parents
|
||||
switch (event.KeyCode())
|
||||
{
|
||||
#ifndef __WXMSW__ // mimic the standard win32 tree ctrl
|
||||
case '+':
|
||||
case WXK_ADD:
|
||||
if (m_current->HasPlus() && !IsExpanded(m_current))
|
||||
@@ -3549,6 +3550,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
||||
Expand(m_current);
|
||||
}
|
||||
break;
|
||||
#endif // __WXMSW__
|
||||
|
||||
case '*':
|
||||
case WXK_MULTIPLY:
|
||||
@@ -3560,6 +3562,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
||||
}
|
||||
//else: fall through to Collapse() it
|
||||
|
||||
#ifndef __WXMSW__ // mimic the standard wxTreeCtrl behaviour
|
||||
case '-':
|
||||
case WXK_SUBTRACT:
|
||||
if (IsExpanded(m_current))
|
||||
@@ -3567,6 +3570,7 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
||||
Collapse(m_current);
|
||||
}
|
||||
break;
|
||||
#endif // __WXMSW__
|
||||
|
||||
case ' ':
|
||||
case WXK_RETURN:
|
||||
@@ -3626,6 +3630,13 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
||||
|
||||
// left arrow goes to the parent
|
||||
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 );
|
||||
if ((prev == GetRootItem()) && HasFlag(wxTR_HIDE_ROOT))
|
||||
@@ -3642,6 +3653,14 @@ void wxTreeListMainWindow::OnChar( wxKeyEvent &event )
|
||||
break;
|
||||
|
||||
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
|
||||
// also expand the item if it wasn't expanded yet
|
||||
Expand(m_current);
|
||||
|
Reference in New Issue
Block a user