本文整理汇总了C++中wxArrayInt::Empty方法的典型用法代码示例。如果您正苦于以下问题:C++ wxArrayInt::Empty方法的具体用法?C++ wxArrayInt::Empty怎么用?C++ wxArrayInt::Empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxArrayInt
的用法示例。
在下文中一共展示了wxArrayInt::Empty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: GetCheckedItems
unsigned int PositionsPopup::GetCheckedItems(wxArrayInt &checkedItems) const
{
unsigned int const itemsCount = GetCount();
checkedItems.Empty();
for( unsigned int i = 0; i < itemsCount; ++i )
{
if( IsChecked( i ) )
checkedItems.Add( i );
}
return checkedItems.GetCount();
}
示例4: GetPartialTextExtents
bool wxTextMeasureBase::GetPartialTextExtents(const wxString& text,
wxArrayInt& widths,
double scaleX)
{
widths.Empty();
if ( text.empty() )
return true;
MeasuringGuard guard(*this);
widths.Add(0, text.length());
return DoGetPartialTextExtents(text, widths, scaleX);
}
示例5: ListGetSelections
int wxMacDataBrowserListControl::ListGetSelections( wxArrayInt& aSelections ) const
{
aSelections.Empty();
wxArrayMacDataItemPtr selectedItems;
GetItems( wxMacDataBrowserRootContainer, false , kDataBrowserItemIsSelected, selectedItems);
int count = selectedItems.GetCount();
for ( int i = 0; i < count; ++i)
{
aSelections.Add(GetLineFromItem(selectedItems[i]));
}
return count;
}
示例6: MacGetSelections
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
{
int no_sel = 0 ;
aSelections.Empty();
Cell cell = { 0 , 0 } ;
cell.v = 0 ;
while ( LGetSelect( true , &cell ,(ListHandle) m_macList ) )
{
aSelections.Add( cell.v ) ;
no_sel++ ;
cell.v++ ;
}
return no_sel ;
}
示例7: DoGetPartialTextExtents
bool wxDCBase::DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const
{
int totalWidth = 0;
size_t i, len = text.Length();
widths.Empty();
widths.Add(0, len);
int w, h;
// reset the cache if font or horizontal scale have changed
if (!s_fontWidthCache.m_widths ||
(s_fontWidthCache.m_scaleX != m_scaleX) ||
(s_fontWidthCache.m_font != GetFont()))
{
s_fontWidthCache.Reset();
s_fontWidthCache.m_font = GetFont();
s_fontWidthCache.m_scaleX = m_scaleX;
}
// Calculate the position of each character based on the widths of
// the previous characters
for (i=0; i<len; i++)
{
const wxChar c = text[i];
unsigned int c_int = (unsigned int)c;
if ((c_int < FWC_SIZE) && (s_fontWidthCache.m_widths[c_int] != 0))
{
w = s_fontWidthCache.m_widths[c_int];
}
else
{
GetTextExtent(c, &w, &h);
if (c_int < FWC_SIZE)
s_fontWidthCache.m_widths[c_int] = w;
}
totalWidth += w;
widths[i] = totalWidth;
}
return true;
}
示例8: 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();
}
}
示例9: MacGetSelections
int wxListBox::MacGetSelections( wxArrayInt& aSelections ) const
{
int no_sel = 0 ;
aSelections.Empty();
UInt32 first , last ;
m_peer->GetSelectionAnchor( &first , &last ) ;
if ( first != kDataBrowserNoItem )
{
for ( size_t i = first ; i <= last ; ++i )
{
if ( m_peer->IsItemSelected( i ) )
{
aSelections.Add( i - 1 ) ;
no_sel++ ;
}
}
}
return no_sel ;
}
示例10: wxGetMultipleChoices
size_t wxGetMultipleChoices(wxArrayInt& selections,
const wxString& message,
const wxString& caption,
int n, const wxString *choices,
wxWindow *parent,
int WXUNUSED(x), int WXUNUSED(y),
bool WXUNUSED(centre),
int WXUNUSED(width), int WXUNUSED(height))
{
wxMultiChoiceDialog dialog(parent, message, caption, n, choices);
// call this even if selections array is empty and this then (correctly)
// deselects the first item which is selected by default
dialog.SetSelections(selections);
if ( dialog.ShowModal() == wxID_OK )
selections = dialog.GetSelections();
else
selections.Empty();
return selections.GetCount();
}
示例11: GetSelections
int wxListBox::GetSelections( wxArrayInt& aSelections ) const
{
wxCHECK_MSG( m_treeview != NULL, wxNOT_FOUND, wxT("invalid listbox") );
aSelections.Empty();
int i = 0;
GtkTreeIter iter;
GtkTreeSelection* selection = gtk_tree_view_get_selection(m_treeview);
if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(m_liststore), &iter))
{ //gtk_tree_selection_get_selected_rows is GTK 2.2+ so iter instead
do
{
if (gtk_tree_selection_iter_is_selected(selection, &iter))
aSelections.Add(i);
i++;
} while(gtk_tree_model_iter_next(GTK_TREE_MODEL(m_liststore), &iter));
}
return aSelections.GetCount();
}
示例12: 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