本文整理汇总了C++中wxArrayStringsAdapter::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ wxArrayStringsAdapter::GetCount方法的具体用法?C++ wxArrayStringsAdapter::GetCount怎么用?C++ wxArrayStringsAdapter::GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wxArrayStringsAdapter
的用法示例。
在下文中一共展示了wxArrayStringsAdapter::GetCount方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoInsertItems
int wxChoice::DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData, wxClientDataType type)
{
MSWAllocStorage(items, CB_INITSTORAGE);
const bool append = pos == GetCount();
// use CB_ADDSTRING when appending at the end to make sure the control is
// resorted if it has wxCB_SORT style
const unsigned msg = append ? CB_ADDSTRING : CB_INSERTSTRING;
if ( append )
pos = 0;
int n = wxNOT_FOUND;
const unsigned numItems = items.GetCount();
for ( unsigned i = 0; i < numItems; ++i )
{
n = MSWInsertOrAppendItem(pos, items[i], msg);
if ( n == wxNOT_FOUND )
return n;
if ( !append )
pos++;
AssignNewItemClientData(n, clientData, i, type);
}
// we need to refresh our size in order to have enough space for the
// newly added items
if ( !IsFrozen() )
MSWUpdateDropDownHeight();
InvalidateBestSize();
return n;
}
示例2: DoInsertItems
int wxChoice::DoInsertItems(const wxArrayStringsAdapter & items,
unsigned int pos,
void **clientData, wxClientDataType type)
{
const unsigned int numItems = items.GetCount();
for( unsigned int i = 0; i < numItems; ++i, ++pos )
{
unsigned int idx;
#if wxUSE_STD_CONTAINERS
if ( IsSorted() )
{
wxArrayString::iterator
insertPoint = std::lower_bound( m_strings.begin(), m_strings.end(), items[i] );
idx = insertPoint - m_strings.begin();
m_strings.insert( insertPoint, items[i] );
}
else
#endif // wxUSE_STD_CONTAINERS
{
idx = pos;
m_strings.Insert( items[i], idx );
}
wxString text = items[i];
if (text == wxEmptyString)
text = " "; // menu items can't have empty labels
m_popUpMenu->Insert( idx, i+1, text );
m_datas.Insert( NULL, idx );
AssignNewItemClientData(idx, clientData, i, type);
}
DoAfterItemCountChange();
return pos - 1;
}
示例3: DoInsertItems
int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items,
unsigned int pos,
void **clientData, wxClientDataType type)
{
const unsigned int numItems = items.GetCount();
int index;
if ( HasFlag(wxCB_SORT) )
{
// Since we don't know at what positions new elements will be actually inserted
// we need to add them one by one, check for each one the position it was added at
// and reserve the slot for corresponding bitmap at the same postion in the bitmap array.
index = pos;
for ( unsigned int i = 0; i < numItems; i++ )
{
if ( clientData )
index = wxComboBox::DoInsertItems(items[i], pos+i, clientData+i, type);
else
index = wxComboBox::DoInsertItems(items[i], pos+i, NULL, wxClientData_None);
wxASSERT_MSG( index != wxNOT_FOUND, wxS("Invalid wxBitmapComboBox state") );
if ( index == wxNOT_FOUND )
{
continue;
}
// Update the bitmap array.
if ( GetCount() > m_bitmaps.Count() )
{
wxASSERT_MSG( GetCount() == m_bitmaps.Count() + 1,
wxS("Invalid wxBitmapComboBox state") );
// Control is in the normal state.
// New item has been just added.
// Insert bitmap at the given index into the array.
wxASSERT_MSG( (size_t)index <= m_bitmaps.Count(),
wxS("wxBitmapComboBox item index out of bound") );
m_bitmaps.Insert(new wxBitmap(wxNullBitmap), index);
}
else
{
// No. of items after insertion <= No. bitmaps:
// (This can happen if control is e.g. recreated with RecreateControl).
// In this case existing bitmaps are reused.
// Required and actual indices should be the same to assure
// consistency between list of items and bitmap array.
wxASSERT_MSG( (size_t)index < m_bitmaps.Count(),
wxS("wxBitmapComboBox item index out of bound") );
wxASSERT_MSG( (unsigned int)index == pos+i,
wxS("Invalid index for wxBitmapComboBox item") );
}
}
}
else
{
if ( GetCount() == m_bitmaps.Count() )
{
// Control is in the normal state.
// Just insert new bitmaps into the array.
const unsigned int countNew = GetCount() + numItems;
m_bitmaps.Alloc(countNew);
for ( unsigned int i = 0; i < numItems; i++ )
{
m_bitmaps.Insert(new wxBitmap(wxNullBitmap), pos + i);
}
}
else
{
wxASSERT_MSG( GetCount() < m_bitmaps.Count(),
wxS("Invalid wxBitmapComboBox state") );
// There are less items then bitmaps.
// (This can happen if control is e.g. recreated with RecreateControl).
// In this case existing bitmaps are reused.
// The whole block of inserted items should be within the range
// of indices of the existing bitmap array.
wxASSERT_MSG( pos + numItems <= m_bitmaps.Count(),
wxS("wxBitmapComboBox item index out of bound") );
}
index = wxComboBox::DoInsertItems(items, pos,
clientData, type);
// This returns index of the last item in the inserted block.
if ( index == wxNOT_FOUND )
{
for ( int i = numItems-1; i >= 0; i-- )
BCBDoDeleteOneItem(pos + i);
}
else
{
// Index of the last inserted item should be consistent
// with required position and number of items.
wxASSERT_MSG( (unsigned int)index == pos+numItems-1,
wxS("Invalid index for wxBitmapComboBox item") );
}
}
return index;
}
示例4: DoInsertItems
int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
unsigned int pos,
void **clientData,
wxClientDataType type)
{
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
DisableEvents();
GtkWidget *list = GTK_COMBO(m_widget)->list;
GtkRcStyle *style = CreateWidgetStyle();
const unsigned int count = items.GetCount();
for( unsigned int i = 0; i < count; ++i, ++pos )
{
GtkWidget *
list_item = gtk_list_item_new_with_label( wxGTK_CONV( items[i] ) );
if ( pos == GetCount() )
{
gtk_container_add( GTK_CONTAINER(list), list_item );
}
else // insert, not append
{
GList *gitem_list = g_list_alloc ();
gitem_list->data = list_item;
gtk_list_insert_items( GTK_LIST (list), gitem_list, pos );
}
if (GTK_WIDGET_REALIZED(m_widget))
{
gtk_widget_realize( list_item );
gtk_widget_realize( GTK_BIN(list_item)->child );
if (style)
{
gtk_widget_modify_style( GTK_WIDGET( list_item ), style );
GtkBin *bin = GTK_BIN( list_item );
GtkWidget *label = GTK_WIDGET( bin->child );
gtk_widget_modify_style( label, style );
}
}
gtk_widget_show( list_item );
if ( m_clientDataList.GetCount() < GetCount() )
m_clientDataList.Insert( pos, NULL );
if ( m_clientObjectList.GetCount() < GetCount() )
m_clientObjectList.Insert( pos, NULL );
AssignNewItemClientData(pos, clientData, i, type);
}
if ( style )
gtk_rc_style_unref( style );
EnableEvents();
InvalidateBestSize();
return pos - 1;
}