int wxListBox::GetSelections( wxArrayInt& aSelections ) const { wxCHECK_MSG( m_list != NULL, wxNOT_FOUND, wxT("invalid listbox") ); // get the number of selected items first GList *child = m_list->children; int count = 0; for (child = m_list->children; child != NULL; child = child->next) { if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) count++; } aSelections.Empty(); if (count > 0) { // now fill the list aSelections.Alloc(count); // optimization attempt int i = 0; for (child = m_list->children; child != NULL; child = child->next, i++) { if (GTK_WIDGET(child->data)->state == GTK_STATE_SELECTED) aSelections.Add(i); } } return count; }
// Return number of selections and an array of selected integers int wxListBox::GetSelections(wxArrayInt& aSelections) const { aSelections.Empty(); Widget listBox = (Widget) m_mainWidget; int *posList = NULL; int posCnt = 0; bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt); if (flag) { if (posCnt > 0) { aSelections.Alloc(posCnt); int i; for (i = 0; i < posCnt; i++) aSelections.Add(posList[i] - 1); XtFree ((char *) posList); return posCnt; } else return 0; } else return 0; }
void CMusikLibrary::Query( const wxString & query, wxArrayInt & aReturn ,bool bClearArray ) { if(bClearArray) { aReturn.Clear(); //--- run the query ---// aReturn.Alloc( GetSongCount() ); } MusikDb::ResultCB cb(&aReturn, &db_callbackAddToIntArray); m_pDB->Exec( ConvQueryToMB( query ), cb ); }
// Return number of selections and an array of selected integers int wxListBox::GetSelections(wxArrayInt& aSelections) const { aSelections.Empty(); if ( HasMultipleSelection() ) { int countSel = ListBox_GetSelCount(GetHwnd()); if ( countSel == LB_ERR ) { wxLogDebug(wxT("ListBox_GetSelCount failed")); } else if ( countSel != 0 ) { int *selections = new int[countSel]; if ( ListBox_GetSelItems(GetHwnd(), countSel, selections) == LB_ERR ) { wxLogDebug(wxT("ListBox_GetSelItems failed")); countSel = -1; } else { aSelections.Alloc(countSel); for ( int n = 0; n < countSel; n++ ) aSelections.Add(selections[n]); } delete [] selections; } return countSel; } else // single-selection listbox { if (ListBox_GetCurSel(GetHwnd()) > -1) aSelections.Add(ListBox_GetCurSel(GetHwnd())); return aSelections.Count(); } }
int wxListBox::GetSelections( wxArrayInt& raSelections ) const { int nCount = 0; LONG lItem; raSelections.Empty(); if (HasMultipleSelection()) { lItem = LONGFROMMR(::WinSendMsg( GetHwnd() ,LM_QUERYSELECTION ,(MPARAM)LIT_FIRST ,(MPARAM)0 ) ); if (lItem != LIT_NONE) { nCount++; while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd() ,LM_QUERYSELECTION ,(MPARAM)lItem ,(MPARAM)0 ) )) != LIT_NONE) { nCount++; } raSelections.Alloc(nCount); lItem = LONGFROMMR(::WinSendMsg( GetHwnd() ,LM_QUERYSELECTION ,(MPARAM)LIT_FIRST ,(MPARAM)0 ) ); raSelections.Add((int)lItem); while ((lItem = LONGFROMMR(::WinSendMsg( GetHwnd() ,LM_QUERYSELECTION ,(MPARAM)lItem ,(MPARAM)0 ) )) != LIT_NONE) { raSelections.Add((int)lItem); } return nCount; } } else // single-selection listbox { lItem = LONGFROMMR(::WinSendMsg( GetHwnd() ,LM_QUERYSELECTION ,(MPARAM)LIT_FIRST ,(MPARAM)0 ) ); raSelections.Add((int)lItem); return 1; } return 0; } // end of wxListBox::GetSelections