本文整理汇总了C++中wxArrayInt::Alloc方法的典型用法代码示例。如果您正苦于以下问题:C++ wxArrayInt::Alloc方法的具体用法?C++ wxArrayInt::Alloc怎么用?C++ wxArrayInt::Alloc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxArrayInt
的用法示例。
在下文中一共展示了wxArrayInt::Alloc方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetSelections
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;
}
示例2: GetSelections
// 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;
}
示例3: Query
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 );
}
示例4: GetSelections
// 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();
}
}
示例5: GetSelections
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