Line-up interfaces to use size_t for GetCount()s (and count related api).
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38076 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "wx/defs.h"
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#if wxUSE_CHOICE
|
||||
|
||||
@@ -133,7 +133,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id,
|
||||
|
||||
GtkWidget *menu = gtk_menu_new();
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
for (size_t i = 0; i < (size_t)n; i++)
|
||||
{
|
||||
GtkAddHelper(menu, i, choices[i]);
|
||||
}
|
||||
@@ -167,9 +167,9 @@ int wxChoice::DoAppend( const wxString &item )
|
||||
int wxChoice::DoInsert( const wxString &item, int pos )
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") );
|
||||
wxCHECK_MSG( (pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
|
||||
wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index"));
|
||||
|
||||
if (pos == GetCount())
|
||||
if ((size_t)pos == GetCount())
|
||||
return DoAppend(item);
|
||||
|
||||
GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
|
||||
@@ -181,7 +181,7 @@ int wxChoice::DoInsert( const wxString &item, int pos )
|
||||
m_selection_hack++;
|
||||
}
|
||||
|
||||
return GtkAddHelper(menu, pos, item);
|
||||
return GtkAddHelper(menu, (size_t)pos, item);
|
||||
}
|
||||
|
||||
void wxChoice::DoSetItemClientData( int n, void* clientData )
|
||||
@@ -262,10 +262,10 @@ void wxChoice::Delete( int n )
|
||||
|
||||
// VZ: apparently GTK+ doesn't have a built-in function to do it (not even
|
||||
// in 2.0), hence this dumb implementation -- still better than nothing
|
||||
int i,
|
||||
count = GetCount();
|
||||
int i;
|
||||
size_t count = GetCount();
|
||||
|
||||
wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") );
|
||||
wxCHECK_RET( IsValid(n), _T("invalid index in wxChoice::Delete") );
|
||||
|
||||
// if the item to delete is before the selection, and the selection is valid
|
||||
if ((n < m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
|
||||
@@ -287,7 +287,7 @@ void wxChoice::Delete( int n )
|
||||
wxArrayString items;
|
||||
wxArrayPtrVoid itemsData;
|
||||
items.Alloc(count);
|
||||
for ( i = 0; i < count; i++ )
|
||||
for ( i = 0; (size_t)i < count; i++ )
|
||||
{
|
||||
if ( i != n )
|
||||
{
|
||||
@@ -432,12 +432,12 @@ wxString wxChoice::GetString( int n ) const
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
int wxChoice::GetCount() const
|
||||
size_t wxChoice::GetCount() const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid choice") );
|
||||
|
||||
GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
GList *child = menu_shell->children;
|
||||
while (child)
|
||||
{
|
||||
@@ -455,7 +455,7 @@ void wxChoice::SetSelection( int n )
|
||||
gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
|
||||
|
||||
// set the local selection variable manually
|
||||
if ((n >= 0) && (n < GetCount()))
|
||||
if ((n >= 0) && ((size_t)n < GetCount()))
|
||||
{
|
||||
// a valid selection has been made
|
||||
m_selection_hack = n;
|
||||
@@ -498,9 +498,9 @@ void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style)
|
||||
}
|
||||
}
|
||||
|
||||
int wxChoice::GtkAddHelper(GtkWidget *menu, int pos, const wxString& item)
|
||||
int wxChoice::GtkAddHelper(GtkWidget *menu, size_t pos, const wxString& item)
|
||||
{
|
||||
wxCHECK_MSG((pos>=0) && (pos<=(int)m_clientList.GetCount()), -1, wxT("invalid index"));
|
||||
wxCHECK_MSG(pos<=m_clientList.GetCount(), -1, wxT("invalid index"));
|
||||
|
||||
GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
|
||||
|
||||
|
||||
@@ -10,10 +10,10 @@
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#include "wx/combobox.h"
|
||||
|
||||
#if wxUSE_COMBOBOX
|
||||
|
||||
#include "wx/combobox.h"
|
||||
|
||||
#include "wx/settings.h"
|
||||
#include "wx/arrstr.h"
|
||||
#include "wx/intl.h"
|
||||
@@ -347,11 +347,11 @@ int wxComboBox::DoAppend( const wxString &item )
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
const int count = GetCount();
|
||||
const size_t count = GetCount();
|
||||
|
||||
if ( (int)m_clientDataList.GetCount() < count )
|
||||
if ( m_clientDataList.GetCount() < count )
|
||||
m_clientDataList.Append( (wxObject*) NULL );
|
||||
if ( (int)m_clientObjectList.GetCount() < count )
|
||||
if ( m_clientObjectList.GetCount() < count )
|
||||
m_clientObjectList.Append( (wxObject*) NULL );
|
||||
|
||||
EnableEvents();
|
||||
@@ -368,10 +368,9 @@ int wxComboBox::DoInsert( const wxString &item, int pos )
|
||||
|
||||
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
|
||||
|
||||
int count = GetCount();
|
||||
wxCHECK_MSG( (pos >= 0) && (pos <= count), -1, wxT("invalid index") );
|
||||
wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") );
|
||||
|
||||
if (pos == count)
|
||||
if ((size_t)pos == GetCount())
|
||||
return Append(item);
|
||||
|
||||
DisableEvents();
|
||||
@@ -394,11 +393,11 @@ int wxComboBox::DoInsert( const wxString &item, int pos )
|
||||
|
||||
gtk_widget_show( list_item );
|
||||
|
||||
count = GetCount();
|
||||
const size_t count = GetCount();
|
||||
|
||||
if ( (int)m_clientDataList.GetCount() < count )
|
||||
if ( m_clientDataList.GetCount() < count )
|
||||
m_clientDataList.Insert( pos, (wxObject*) NULL );
|
||||
if ( (int)m_clientObjectList.GetCount() < count )
|
||||
if ( m_clientObjectList.GetCount() < count )
|
||||
m_clientObjectList.Insert( pos, (wxObject*) NULL );
|
||||
|
||||
EnableEvents();
|
||||
@@ -455,7 +454,7 @@ void wxComboBox::Clear()
|
||||
DisableEvents();
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
gtk_list_clear_items( GTK_LIST(list), 0, GetCount() );
|
||||
gtk_list_clear_items( GTK_LIST(list), 0, (int)GetCount() );
|
||||
|
||||
wxList::compatibility_iterator node = m_clientObjectList.GetFirst();
|
||||
while (node)
|
||||
@@ -581,7 +580,7 @@ int wxComboBox::GetCurrentSelection() const
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
return wxNOT_FOUND;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetString( int n ) const
|
||||
@@ -626,14 +625,14 @@ wxString wxComboBox::GetStringSelection() const
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
int wxComboBox::GetCount() const
|
||||
size_t wxComboBox::GetCount() const
|
||||
{
|
||||
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") );
|
||||
|
||||
GtkWidget *list = GTK_COMBO(m_widget)->list;
|
||||
|
||||
GList *child = GTK_LIST(list)->children;
|
||||
int count = 0;
|
||||
size_t count = 0;
|
||||
while (child) { count++; child = child->next; }
|
||||
return count;
|
||||
}
|
||||
@@ -798,7 +797,7 @@ void wxComboBox::Replace( long from, long to, const wxString& value )
|
||||
wxCharBuffer buffer = wxConvUTF8.cWX2MB( value );
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos );
|
||||
#else
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.Length(), &pos );
|
||||
gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ static gint wxlistbox_idle_callback( gpointer gdata )
|
||||
// check that the items haven't been deleted from the listbox since we had
|
||||
// installed this callback
|
||||
wxListBox *lbox = data->m_listbox;
|
||||
if ( data->m_item < lbox->GetCount() )
|
||||
if ( data->m_item < (int)lbox->GetCount() )
|
||||
{
|
||||
lbox->SetFirstItem( data->m_item );
|
||||
}
|
||||
@@ -583,7 +583,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||
|
||||
// code elsewhere supposes we have as many items in m_clientList as items
|
||||
// in the listbox
|
||||
wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
|
||||
wxASSERT_MSG( m_clientList.GetCount() == GetCount(),
|
||||
wxT("bug in client data management") );
|
||||
|
||||
InvalidateBestSize();
|
||||
@@ -602,7 +602,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||
{
|
||||
index = m_strings->Add( items[n] );
|
||||
|
||||
if (index != GetCount())
|
||||
if (index != (int)GetCount())
|
||||
{
|
||||
GtkAddItem( items[n], index );
|
||||
wxList::compatibility_iterator node = m_clientList.Item( index );
|
||||
@@ -638,7 +638,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
|
||||
}
|
||||
}
|
||||
|
||||
wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
|
||||
wxASSERT_MSG( m_clientList.GetCount() == GetCount(),
|
||||
wxT("bug in client data management") );
|
||||
}
|
||||
|
||||
@@ -652,7 +652,7 @@ int wxListBox::DoAppend( const wxString& item )
|
||||
int index = m_strings->Add( item );
|
||||
|
||||
// only if not at the end anyway
|
||||
if (index != GetCount())
|
||||
if (index != (int)GetCount())
|
||||
{
|
||||
GtkAddItem( item, index );
|
||||
|
||||
@@ -773,7 +773,7 @@ void wxListBox::Clear()
|
||||
{
|
||||
wxCHECK_RET( m_list != NULL, wxT("invalid listbox") );
|
||||
|
||||
gtk_list_clear_items( m_list, 0, GetCount() );
|
||||
gtk_list_clear_items( m_list, 0, (int)GetCount() );
|
||||
|
||||
if ( GTK_LIST(m_list)->last_focus_child != NULL )
|
||||
{
|
||||
@@ -938,9 +938,9 @@ wxString wxListBox::GetString( int n ) const
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
int wxListBox::GetCount() const
|
||||
size_t wxListBox::GetCount() const
|
||||
{
|
||||
wxCHECK_MSG( m_list != NULL, -1, wxT("invalid listbox") );
|
||||
wxCHECK_MSG( m_list != NULL, 0, wxT("invalid listbox") );
|
||||
|
||||
GList *children = m_list->children;
|
||||
return g_list_length(children);
|
||||
@@ -1216,7 +1216,7 @@ wxSize wxListBox::DoGetBestSize() const
|
||||
int wLine;
|
||||
|
||||
// Find the widest line
|
||||
for(int i = 0; i < GetCount(); i++) {
|
||||
for(size_t i = 0; i < GetCount(); i++) {
|
||||
wxString str(GetString(i));
|
||||
GetTextExtent(str, &wLine, NULL);
|
||||
lbWidth = wxMax(lbWidth, wLine);
|
||||
|
||||
@@ -492,7 +492,7 @@ bool wxRadioBox::IsItemShown(int item) const
|
||||
return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
|
||||
}
|
||||
|
||||
int wxRadioBox::GetCount() const
|
||||
size_t wxRadioBox::GetCount() const
|
||||
{
|
||||
return m_boxes.GetCount();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user