public:
virtual void Clear();
virtual void Delete(int);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int) const;
virtual void SetString(int, const wxString&);
virtual int FindString(const wxString& s, bool bCase = false) const;
// wxItemContainer
virtual void Clear();
virtual void Delete(int);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int) const;
virtual void SetString(int, const wxString&);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual void Clear();
virtual void Delete(int n);
// accessing strings
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
// Author: David Elliott
// Modified by:
// Created: 2003/03/18
-// RCS-ID: $Id:
+// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
virtual void SetSelection(int n);
virtual int GetSelection() const;
// string access
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label);
// change the individual radio button state
// accessing strings
// -----------------
- virtual int GetCount() const = 0;
+ virtual size_t GetCount() const = 0;
bool IsEmpty() const { return GetCount() == 0; }
virtual wxString GetString(int n) const = 0;
// supported search type
virtual int FindString(const wxString& s, bool bCase = false) const
{
- int count = GetCount();
+ size_t count = GetCount();
- for ( int i = 0; i < count ; i ++ )
+ for ( size_t i = 0; i < count ; ++i )
{
if (GetString(i).IsSameAs( s , bCase ))
return i;
protected:
// check that the index is valid
- inline bool IsValid(int n) const { return n >= 0 && n < GetCount(); }
+ // FIXME: once api will move to size_t, drop >= 0 check
+ inline bool IsValid(int n) const { return n >= 0 && (size_t)n < GetCount(); }
+ inline bool IsValidInsert(int n) const { return n >= 0 && (size_t)n <= GetCount(); }
};
class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable
int GetCurrentSelection() const { return GetSelection(); }
void SetSelection( int n );
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int FindString(const wxString& s, bool bCase = false) const;
wxString GetString( int n ) const;
void SetString( int n, const wxString& string );
private:
// common part of Create() and DoAppend()
- int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item);
+ int GtkAddHelper(GtkWidget *menu, size_t pos, const wxString& item);
// this array is only used for controls with wxCB_SORT style, so only
// allocate it if it's needed (hence using pointer)
int GetCurrentSelection() const;
wxString GetString( int n ) const;
wxString GetStringSelection() const;
- int GetCount() const;
- int Number() const { return GetCount(); }
+ virtual size_t GetCount() const;
void SetSelection( int n );
void SetString(int n, const wxString &text);
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
bool m_spacePressed;
struct _GtkTreeEntry* GtkGetEntry(int pos) const;
- void GtkInsertItems(const wxArrayString& items,
- void** clientData, int pos);
+ void GtkInsertItems(const wxArrayString& items,
+ void** clientData, size_t pos);
void GtkSetSelection(int n, const bool select, const bool blockEvent);
protected:
// implement wxItemContainerImmutable methods
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
int GetCurrentSelection() const { return GetSelection(); }
void SetSelection( int n );
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int FindString(const wxString& s, bool bCase = false) const;
wxString GetString( int n ) const;
void SetString( int n, const wxString& string );
private:
// common part of Create() and DoAppend()
- int GtkAddHelper(GtkWidget *menu, int pos, const wxString& item);
+ int GtkAddHelper(GtkWidget *menu, size_t pos, const wxString& item);
// this array is only used for controls with wxCB_SORT style, so only
// allocate it if it's needed (hence using pointer)
int GetCurrentSelection() const;
wxString GetString( int n ) const;
wxString GetStringSelection() const;
- int GetCount() const;
- int Number() const { return GetCount(); }
+ virtual size_t GetCount() const;
void SetSelection( int n );
void SetString(int n, const wxString &text);
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
// implement wxItemContainerImmutable methods
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual void Delete(int n);
virtual void Clear();
- virtual int GetCount() const ;
+ virtual size_t GetCount() const ;
virtual int GetSelection() const ;
virtual void SetSelection(int n);
int GetCurrentSelection() const { return GetSelection(); }
virtual void SetEditable(bool editable);
virtual bool IsEditable() const;
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual void Undo();
virtual void Redo();
const wxString& name = wxListBoxNameStr);
virtual ~wxListBox();
- virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
+ virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
// implement base class pure virtuals
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
// prevent collision with some BSD definitions of macro Free()
void FreeData();
- int m_noItems;
+ size_t m_noItems;
int m_selected;
bool m_suppressSelection ;
wxString m_typeIn ;
/////////////////////////////////////////////////////////////////////////////
-// Name: radiobox.h
+// Name: wx/mac/carbon/radiobox.h
// Purpose: wxRadioBox class
// Author: Stefan Csomor
// Modified by:
virtual void SetSelection(int item);
virtual int GetSelection() const;
- inline virtual int GetCount() const { return m_noItems; } ;
+ virtual size_t GetCount() const { return m_noItems; } ;
virtual wxString GetString(int item) const;
virtual void SetString(int item, const wxString& label) ;
inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
void OnRadioButton( wxCommandEvent& event ) ;
+
protected:
- wxRadioButton *m_radioButtonCycle;
+ wxRadioButton *m_radioButtonCycle;
- int m_noItems;
+ size_t m_noItems;
int m_noRowsOrCols;
// Internal functions
virtual void Delete(int n);
virtual void Clear();
- virtual int GetCount() const ;
+ virtual size_t GetCount() const ;
virtual int GetSelection() const ;
virtual void SetSelection(int n);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
- virtual int GetCount() const { return m_choice->GetCount() ; }
+ virtual size_t GetCount() const { return m_choice->GetCount() ; }
virtual bool IsEditable() const ;
const wxString& name = wxListBoxNameStr);
virtual ~wxListBox();
- virtual void Refresh(bool eraseBack = TRUE, const wxRect *rect = NULL);
+ virtual void Refresh(bool eraseBack = true, const wxRect *rect = NULL);
// implement base class pure virtuals
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
// prevent collision with some BSD definitions of macro Free()
void FreeData();
- int m_noItems;
+ size_t m_noItems;
int m_selected;
wxString m_typeIn ;
long m_lastTypeIn ;
/////////////////////////////////////////////////////////////////////////////
-// Name: radiobox.h
+// Name: wx/mac/classic/radiobox.h
// Purpose: wxRadioBox class
// Author: Stefan Csomor
// Modified by:
virtual void SetSelection(int item);
virtual int GetSelection() const;
- inline virtual int GetCount() const { return m_noItems; } ;
+ virtual size_t GetCount() const { return m_noItems; } ;
virtual wxString GetString(int item) const;
virtual void SetString(int item, const wxString& label) ;
inline void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
void OnRadioButton( wxCommandEvent& event ) ;
+
protected:
- wxRadioButton *m_radioButtonCycle;
+ wxRadioButton *m_radioButtonCycle;
- int m_noItems;
+ size_t m_noItems;
int m_noRowsOrCols;
// Internal functions
const wxString& name = wxChoiceNameStr);
// implementation of wxControlWithItems
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int DoAppend(const wxString& item);
virtual int DoInsert(const wxString& item, int pos);
virtual void DoSetItemClientData(int n, void* clientData);
~wxListBox();
// implementation of wxControlWithItems
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int DoAppend(const wxString& item);
virtual void DoSetItemClientData(int n, void* clientData);
virtual void* DoGetItemClientData(int n) const;
protected:
virtual wxSize DoGetBestSize() const;
- int m_noItems;
+ size_t m_noItems;
// List mapping positions->client data
wxClientDataDictionary m_clientDataDict;
virtual wxString GetStringSelection() const;
virtual bool SetStringSelection(const wxString& s);
- virtual int GetCount() const { return m_noItems; } ;
+ virtual size_t GetCount() const { return m_noItems; } ;
void Command(wxCommandEvent& event);
int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
int width, int height,
int sizeFlags = wxSIZE_AUTO);
- int m_noItems;
+ size_t m_noItems;
int m_noRowsOrCols;
int m_selectedButton;
virtual void Delete(int n);
virtual void Clear();
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int GetSelection() const;
virtual int GetCurrentSelection() const;
virtual void SetSelection(int n);
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
// free memory (common part of Clear() and dtor)
void Free();
- int m_noItems;
+ size_t m_noItems;
int m_selected;
virtual wxSize DoGetBestSize() const;
// implement the radiobox interface
virtual void SetSelection(int n);
virtual int GetSelection() const { return m_selectedButton; }
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label);
virtual bool Enable(int n, bool enable = true);
// public interface derived from wxListBox and lower classes
virtual void Clear();
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int GetSelection() const;
virtual int GetSelections(wxArrayInt& aSelections) const;
virtual wxString GetString(int n) const;
virtual void Delete(int n);
virtual void Clear() ;
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int GetSelection() const;
virtual void SetSelection(int n);
virtual void Delete(int n);
virtual void Clear(void);
- virtual int GetCount(void) const;
+ virtual size_t GetCount() const;
virtual int GetSelection(void) const ;
virtual void SetSelection(int n);
virtual void Clear(void);
virtual void Delete(int n);
- virtual int GetCount(void) const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& rsString);
virtual bool IsSelected(int n) const;
- virtual void DoSetSelection( int n
- ,bool bSelect
- );
+ virtual void DoSetSelection(int n, bool bSelect);
virtual int GetSelection(void) const;
virtual int GetSelections(wxArrayInt& raSelections) const;
virtual int DoAppend(const wxString& rsItem);
- virtual void DoInsertItems( const wxArrayString& raItems
- ,int rPos
- );
+ virtual void DoInsertItems( const wxArrayString& raItems, int rPos );
virtual void DoSetItems( const wxArrayString& raItems
,void ** ppClientData
);
bool HasMultipleSelection(void) const;
virtual wxSize DoGetBestSize(void) const;
- int m_nNumItems;
- int m_nSelected;
-
+ size_t m_nNumItems;
+ int m_nSelected;
#if wxUSE_OWNER_DRAWN
//
- virtual int GetCount(void) const;
+ virtual size_t GetCount() const;
inline WXHWND* GetRadioButtons(void) const { return m_ahRadioButtons; }
int GetSelection(void) const;
void GetSize( int* pnX
WXHWND* m_ahRadioButtons;
int* m_pnRadioWidth; // for bitmaps
int* m_pnRadioHeight;
- int m_nNoItems;
int m_nSelectedButton;
int m_nSizeFlags;
private:
+ size_t m_nNoItems;
+
DECLARE_DYNAMIC_CLASS(wxRadioBox)
}; // end of wxRadioBox
virtual void Delete(int n);
virtual void Clear();
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual int GetSelection() const;
virtual void SetSelection(int n);
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
// free memory (common part of Clear() and dtor)
void Free();
- int m_noItems;
int m_selected;
virtual wxSize DoGetBestSize() const;
// implement the radiobox interface
virtual void SetSelection(int n);
virtual int GetSelection() const;
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label);
// get the total size occupied by the radio box buttons
wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
- int * m_radioWidth; // for bitmaps
- int * m_radioHeight;
+ int *m_radioWidth; // for bitmaps
+ int *m_radioHeight;
- int m_noItems;
- int m_noRowsOrCols;
- int m_selectedButton;
+ int m_noRowsOrCols;
+ int m_selectedButton;
virtual wxSize DoGetBestSize() const;
// wxControlWithItems methods
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const;
+ virtual size_t GetCount() const;
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& s);
virtual int FindString(const wxString& s, bool bCase = false) const;
virtual void Clear();
virtual void Delete(int n);
- virtual int GetCount() const
- { return (int)m_strings->GetCount(); }
+ virtual size_t GetCount() const
+ { return m_strings->GetCount(); }
virtual wxString GetString(int n) const
{ return m_strings->Item(n); }
virtual void SetString(int n, const wxString& s);
virtual void SetSelection(int n);
virtual int GetSelection() const;
- virtual int GetCount() const { return (int) m_buttons.GetCount(); }
+ virtual size_t GetCount() const { return m_buttons.GetCount(); }
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label);
wxString label = m_pListBox->GetString(selection);
int positionNew = up ? selection - 1 : selection + 2;
- if ( positionNew < 0 || positionNew > m_pListBox->GetCount() )
+ if ( positionNew < 0 || positionNew > (int)m_pListBox->GetCount() )
{
wxLogStatus(this, wxT("Can't move this item %s"), up ? wxT("up") : wxT("down"));
}
[(NSPopUpButton*)m_cocoaNSView removeItemAtIndex:n];
}
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
- return [(NSPopUpButton*)m_cocoaNSView numberOfItems];
+ return (size_t)[(NSPopUpButton*)m_cocoaNSView numberOfItems];
}
wxString wxChoice::GetString(int n) const
// ----------------------------------------------------------------------------
#include "wx/wxprec.h"
+
#if wxUSE_COMBOBOX
#ifndef WX_PRECOMP
m_Datas.RemoveAt(nIndex);
}
-int wxComboBox::GetCount() const
+size_t wxComboBox::GetCount() const
{
- return [GetNSComboBox() numberOfItems];
+ return (size_t)[GetNSComboBox() numberOfItems];
}
wxString wxComboBox::GetString(int nIndex) const
/////////////////////////////////////////////////////////////////////////////
-// Name: cocoa/listbox.mm
+// Name: src/cocoa/listbox.mm
// Purpose: wxListBox
// Author: David Elliott
// Modified by:
}
// accessing strings
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
- return [m_cocoaItems count];
+ return (size_t)[m_cocoaItems count];
}
wxString wxListBox::GetString(int n) const
/////////////////////////////////////////////////////////////////////////////
-// Name: cocoa/radiobox.mm
+// Name: src/cocoa/radiobox.mm
// Purpose: wxRadioBox
// Author: David Elliott
// Modified by:
// Created: 2003/02/15
-// RCS-ID: $Id:
+// RCS-ID: $Id$
// Copyright: (c) 2003 David Elliott
// Licence: wxWidgets licence
/////////////////////////////////////////////////////////////////////////////
}
// string access
-int wxRadioBox::GetCount() const
+size_t wxRadioBox::GetCount() const
{
return 0;
}
}
#endif
-
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#include "wx/defs.h"
+#include "wx/wxprec.h"
#if wxUSE_CHOICE
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]);
}
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) );
m_selection_hack++;
}
- return GtkAddHelper(menu, pos, item);
+ return GtkAddHelper(menu, (size_t)pos, item);
}
void wxChoice::DoSetItemClientData( int n, void* clientData )
void wxChoice::Delete( int n )
{
wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxChoice::Delete") );
// 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();
-
- wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") );
+ size_t i;
+ const size_t count = GetCount();
// if the item to delete is before the selection, and the selection is valid
if ((n < m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
items.Alloc(count);
for ( i = 0; i < count; i++ )
{
- if ( i != n )
+ if ( i != (size_t)n )
{
items.Add(GetString(i));
if ( hasClientData )
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)
{
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) && (n < (int)GetCount()))
{
// a valid selection has been made
m_selection_hack = n;
}
}
-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(IsValidInsert(pos), -1, wxT("invalid index"));
GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
// if we're called from ctor (and GtkMenuShell is still NULL)
// normal control, just append
- if (pos == (int)m_clientList.GetCount())
+ if (pos == m_clientList.GetCount())
{
gtk_menu_shell_append( GTK_MENU_SHELL(menu), menu_item );
m_clientList.Append( (wxObject*) NULL );
// 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"
{
m_widget = gtk_combo_box_entry_new_text();
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
-
+
gtk_entry_set_editable( GTK_ENTRY( GTK_BIN(m_widget)->child ), TRUE );
-
+
for (int i = 0; i < n; i++)
{
gtk_combo_box_append_text( combobox, wxGTK_CONV( choices[i] ) );
{
m_widget = gtk_combo_new();
GtkCombo* combo = GTK_COMBO(m_widget);
-
+
// Disable GTK's broken events ...
g_signal_handler_disconnect (combo->entry, combo->entry_change_id);
// ... and add surrogate handler.
if (style & wxNO_BORDER)
g_object_set( GTK_ENTRY( combo->entry ), "has-frame", FALSE, NULL );
-
+
GtkWidget *list = combo->list;
for (int i = 0; i < n; i++)
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
m_focusWidget = GTK_WIDGET( entry );
PostCreation(size);
if (!gtk_check_version(2,4,0))
{
gtk_entry_set_text( entry, wxGTK_CONV(value) );
-
+
if (style & wxCB_READONLY)
gtk_entry_set_editable( entry, FALSE );
-
+
g_signal_connect_after (entry, "changed",
G_CALLBACK (gtkcombobox_text_changed_callback), this);
-
+
g_signal_connect_after (m_widget, "changed",
G_CALLBACK (gtkcombobox_changed_callback), this);
}
this);
g_signal_connect_after (entry, "changed",
G_CALLBACK (gtkcombo_text_changed_callback), this);
-
+
// This is required for tool bar support
// Doesn't currently work
// wxSize setsize = GetSize();
EnableEvents();
}
-
- const int count = GetCount();
- if ( (int)m_clientDataList.GetCount() < count )
+ const size_t count = GetCount();
+
+ 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 );
InvalidateBestSize();
wxT("can't insert into sorted list"));
wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") );
+ wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") );
- int count = GetCount();
- wxCHECK_MSG( (pos >= 0) && (pos <= count), -1, wxT("invalid index") );
+ const size_t count = GetCount();
- if (pos == count)
+ if ((size_t)pos == count)
return Append(item);
#ifdef __WXGTK24__
EnableEvents();
}
-
+
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 );
InvalidateBestSize();
if (!gtk_check_version(2,4,0))
{
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- int i;
+ size_t i;
for (i = 0; i < GetCount(); i++)
gtk_combo_box_remove_text( combobox, 0 );
}
GtkWidget *list = GTK_COMBO(m_widget)->list;
gtk_list_clear_items( GTK_LIST(list), 0, GetCount() );
}
-
+
wxList::compatibility_iterator node = m_clientObjectList.GetFirst();
while (node)
{
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
- wxCHECK_RET( (n >= 0) && (n <= GetCount()), wxT("invalid index") );
-
+ wxCHECK_RET( IsValid(n), wxT("invalid index") );
+
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
gtk_combo_box_remove_text( combobox, n );
}
EnableEvents();
}
-
+
wxList::compatibility_iterator node = m_clientObjectList.Item( n );
if (node)
{
if (!gtk_check_version(2,4,0))
{
GtkComboBox* combobox = GTK_COMBO_BOX( m_widget );
- wxCHECK_RET( (n >= 0) && (n <= GetCount()), wxT("invalid index") );
-
+ wxCHECK_RET( IsValid(n), wxT("invalid index") );
+
GtkTreeModel *model = gtk_combo_box_get_model( combobox );
GtkTreeIter iter;
if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n))
wxFAIL_MSG( wxT("wxComboBox: wrong index") );
}
}
-
+
InvalidateBestSize();
}
if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter ))
return -1;
int count = 0;
- do
+ do
{
GValue value = { 0, };
gtk_tree_model_get_value( model, &iter, 0, &value );
wxString str = wxGTK_CONV_BACK( g_value_get_string( &value ) );
g_value_unset( &value );
-
+
if (item.IsSameAs( str, bCase ) )
return count;
-
+
count++;
-
+
} while (gtk_tree_model_iter_next( model, &iter ));
}
else
wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid combobox") );
wxString str;
-
+
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
}
else
#endif
- {
+ {
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *child = g_list_nth( GTK_LIST(list)->children, n );
}
else
#endif
- {
+ {
GtkWidget *list = GTK_COMBO(m_widget)->list;
GList *selection = GTK_LIST(list)->selection;
return wxEmptyString;
}
-int wxComboBox::GetCount() const
+size_t wxComboBox::GetCount() const
{
wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") );
gtk_tree_model_get_iter_first( model, &iter );
if (!gtk_list_store_iter_is_valid(GTK_LIST_STORE(model), &iter ))
return 0;
- int ret = 1;
+ size_t ret = 1;
while (gtk_tree_model_iter_next( model, &iter ))
ret++;
return ret;
}
else
#endif
- {
+ {
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;
}
-
+
return 0;
}
gtk_list_select_item( GTK_LIST(list), n );
m_prevSelection = n;
}
-
+
EnableEvents();
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
wxString tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry ) ) );
#if 0
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
wxString tmp;
if (!value.IsNull()) tmp = value;
gtk_entry_set_text( entry, wxGTK_CONV( tmp ) );
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_editable_copy_clipboard(GTK_EDITABLE(entry));
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_editable_cut_clipboard(GTK_EDITABLE(entry));
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_editable_paste_clipboard(GTK_EDITABLE(entry));
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_entry_set_position( entry, (int)pos );
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
return (long) gtk_editable_get_position(GTK_EDITABLE(entry));
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
int pos = entry->text_length;
return (long) pos-1;
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
if (value.IsNull()) return;
gint pos = (gint)to;
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
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to );
}
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
if (IsEditable())
{
GtkEditable *editable = GTK_EDITABLE(entry);
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
gtk_entry_set_editable( GTK_ENTRY(entry), editable );
}
#ifdef __WXGTK24__
if (!gtk_check_version(2,4,0))
{
- g_signal_handlers_disconnect_by_func (GTK_BIN(m_widget)->child,
+ g_signal_handlers_disconnect_by_func (GTK_BIN(m_widget)->child,
(gpointer)gtkcombobox_text_changed_callback, this);
-
+
g_signal_handlers_disconnect_by_func (m_widget,
(gpointer)gtkcombobox_changed_callback, this);
}
else
-#endif
+#endif
{
g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->list,
(gpointer) gtkcombo_combo_select_child_callback, this);
-
+
g_signal_handlers_disconnect_by_func (GTK_COMBO(m_widget)->entry,
(gpointer) gtkcombo_text_changed_callback, this);
}
{
g_signal_connect_after (GTK_BIN(m_widget)->child, "changed",
G_CALLBACK (gtkcombobox_text_changed_callback), this);
-
+
g_signal_connect_after (m_widget, "changed",
G_CALLBACK (gtkcombobox_changed_callback), this);
}
else
-#endif
+#endif
{
g_signal_connect_after (GTK_COMBO(m_widget)->list, "select-child",
G_CALLBACK (gtkcombo_combo_select_child_callback),
if (!gtk_check_version(2,4,0))
entry = GTK_ENTRY( GTK_BIN(m_widget)->child );
else
-#endif
+#endif
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
-
+
return GTK_WIDGET( entry );
}
return (window == entry->text_area);
}
else
-#endif
+#endif
{
entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry );
return ( (window == entry->text_area) ||
// ----------------------------------------------------------------------------
void wxListBox::GtkInsertItems(const wxArrayString& items,
- void** clientData, int pos)
+ void** clientData, size_t pos)
{
wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );
// Create and set column ids and GValues
size_t nNum = items.GetCount();
- int nCurCount = wxListBox::GetCount();
+ size_t nCurCount = wxListBox::GetCount();
wxASSERT_MSG(pos <= nCurCount, wxT("Invalid index passed to wxListBox"));
GtkTreeIter* pIter = NULL; // append by default
gboolean res = gtk_tree_model_iter_nth_child(
GTK_TREE_MODEL(m_liststore),
&iter, NULL, //NULL = parent = get first
- pos );
+ (int)pos );
if(!res)
{
wxLogSysError(wxT("internal wxListBox error in insertion"));
wxString label = items[i];
#if wxUSE_CHECKLISTBOX && !wxUSE_NATIVEGTKCHECKLIST
- if (m_hasCheckBoxes)
- {
- label.Prepend(wxCHECKLBOX_STRING);
- }
+ if (m_hasCheckBoxes)
+ {
+ label.Prepend(wxCHECKLBOX_STRING);
+ }
#endif // wxUSE_CHECKLISTBOX
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
- GtkInsertItems(items, NULL, pos);
+ wxCHECK_RET( IsValidInsert(pos), wxT("invalid index in wxListBox::InsertItems") );
+
+ GtkInsertItems(items, NULL, (size_t)pos);
}
int wxListBox::DoAppend( const wxString& item )
{
// Call DoInsertItems
- int nWhere = wxListBox::GetCount();
+ int nWhere = (int)wxListBox::GetCount();
wxArrayString aItems;
aItems.Add(item);
wxListBox::DoInsertItems(aItems, nWhere);
if (!res)
{
wxLogDebug(wxT("gtk_tree_model_iter_nth_child failed\n")
- wxT("Passed in value was:[%i] List size:[%i]"),
+ wxT("Passed in value was:[%i] List size:[%u]"),
n, wxListBox::GetCount() );
return NULL;
}
void* wxListBox::DoGetItemClientData( int n ) const
{
- wxCHECK_MSG( n >= 0 && n < wxListBox::GetCount(), NULL,
+ wxCHECK_MSG( n >= 0 && (size_t)n < wxListBox::GetCount(), NULL,
wxT("Invalid index passed to GetItemClientData") );
GtkTreeEntry* entry = GtkGetEntry(n);
void wxListBox::DoSetItemClientData( int n, void* clientData )
{
- wxCHECK_RET( n >= 0 && n < wxListBox::GetCount(),
+ wxCHECK_RET( n >= 0 && (size_t)n < wxListBox::GetCount(),
wxT("Invalid index passed to SetItemClientData") );
GtkTreeEntry* entry = GtkGetEntry(n);
void wxListBox::SetString( int n, const wxString &string )
{
+ wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetString") );
wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") );
GtkTreeEntry* entry = GtkGetEntry(n);
wxString label = string;
#if wxUSE_CHECKLISTBOX && !wxUSE_NATIVEGTKCHECKLIST
- if (m_hasCheckBoxes)
- label.Prepend(wxCHECKLBOX_STRING);
+ if (m_hasCheckBoxes)
+ label.Prepend(wxCHECKLBOX_STRING);
#endif // wxUSE_CHECKLISTBOX
// RN: This may look wierd but the problem is that the TreeView
wxArrayString aItems;
aItems.Add(label);
- GtkInsertItems(aItems, &userdata, n);
+ GtkInsertItems(aItems, &userdata, (size_t)n);
if (bWasSelected)
wxListBox::GtkSetSelection(n, true, true);
}
return label;
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
- wxCHECK_MSG( m_treeview != NULL, -1, wxT("invalid listbox") );
+ wxCHECK_MSG( m_treeview != NULL, 0, wxT("invalid listbox") );
- return gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_liststore), NULL);
+ return (size_t)gtk_tree_model_iter_n_children(GTK_TREE_MODEL(m_liststore), NULL);
}
int wxListBox::FindString( const wxString &item, bool bCase ) const
wxCHECK_MSG( m_treeview != NULL, wxNOT_FOUND, wxT("invalid listbox") );
//Sort of hackish - maybe there is a faster way
- int nCount = wxListBox::GetCount();
+ size_t nCount = wxListBox::GetCount();
- for(int i = 0; i < nCount; ++i)
+ for(size_t i = 0; i < nCount; ++i)
{
if( item.IsSameAs( wxListBox::GetString(i), bCase ) )
- return i;
+ return (int)i;
}
void wxListBox::DoSetFirstItem( int n )
{
wxCHECK_RET( m_treeview, wxT("invalid listbox") );
- wxCHECK_RET( n >= 0 && n < wxListBox::GetCount(), wxT("invalid index"));
+ wxCHECK_RET( IsValid(n), wxT("invalid index"));
//RN: I have no idea why this line is needed...
if (gdk_pointer_is_grabbed () && GTK_WIDGET_HAS_GRAB (m_treeview))
// Get the visible area of the tree view (limit to the 10th item
// so that it isn't too big)
- int count = GetCount();
+ size_t count = GetCount();
if (count)
{
int wLine;
// Find the widest line
- for(int i = 0; i < count; i++) {
+ for(size_t i = 0; i < count; i++) {
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
lbWidth = wxMax(lbWidth, wLine);
if (!rb->m_hasVMT) return FALSE;
if (g_blockEventsOnDrag) return FALSE;
- if ( ((gdk_event->keyval == GDK_Tab) ||
+ if ( ((gdk_event->keyval == GDK_Tab) ||
(gdk_event->keyval == GDK_ISO_Left_Tab)) &&
rb->GetParent() && (rb->GetParent()->HasFlag( wxTAB_TRAVERSAL)) )
{
return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
}
-int wxRadioBox::GetCount() const
+size_t wxRadioBox::GetCount() const
{
return m_boxes.GetCount();
}
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#include "wx/defs.h"
+#include "wx/wxprec.h"
#if wxUSE_CHOICE
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]);
}
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) );
m_selection_hack++;
}
- return GtkAddHelper(menu, pos, item);
+ return GtkAddHelper(menu, (size_t)pos, item);
}
void wxChoice::DoSetItemClientData( int n, void* clientData )
// 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))
wxArrayString items;
wxArrayPtrVoid itemsData;
items.Alloc(count);
- for ( i = 0; i < count; i++ )
+ for ( i = 0; (size_t)i < count; i++ )
{
if ( i != n )
{
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)
{
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;
}
}
-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 ) );
// 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"
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();
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();
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();
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)
}
}
- return -1;
+ return wxNOT_FOUND;
}
wxString wxComboBox::GetString( int n ) 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;
}
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
}
// 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 );
}
// 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();
{
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 );
}
}
- wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(),
+ wxASSERT_MSG( m_clientList.GetCount() == GetCount(),
wxT("bug in client data management") );
}
int index = m_strings->Add( item );
// only if not at the end anyway
- if (index != GetCount())
+ if (index != (int)GetCount())
{
GtkAddItem( item, index );
{
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 )
{
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);
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);
return GTK_WIDGET_VISIBLE(GTK_WIDGET(button));
}
-int wxRadioBox::GetCount() const
+size_t wxRadioBox::GetCount() const
{
return m_boxes.GetCount();
}
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
int wxChoice::DoInsert( const wxString& item, int pos )
{
wxCHECK_MSG( !(GetWindowStyle() & wxCB_SORT), -1, wxT("wxChoice::DoInsert: can't insert into sorted list") );
- wxCHECK_MSG( (pos >= 0) && (pos <= GetCount()), -1, wxT("wxChoice::DoInsert: invalid index") );
+ wxCHECK_MSG( IsValidInsert(pos), -1, wxT("wxChoice::DoInsert: invalid index") );
- if (pos == GetCount())
+ if ((size_t)pos == GetCount())
return DoAppend( item );
UMAInsertMenuItem( MAC_WXHMENU( m_macPopUpMenuHandle ), item, m_font.GetEncoding(), pos );
void wxChoice::Delete( int n )
{
- wxCHECK_RET( n < GetCount(), wxT("wxChoice::Delete: invalid index") );
+ wxCHECK_RET( IsValid(n) , wxT("wxChoice::Delete: invalid index") );
if ( HasClientObjectData() )
delete GetClientObject( n );
void wxChoice::Clear()
{
FreeData();
- for ( int i = 0 ; i < GetCount() ; i++ )
+ for ( size_t i = 0 ; i < GetCount() ; i++ )
{
::DeleteMenuItem( MAC_WXHMENU(m_macPopUpMenuHandle) , 1 ) ;
}
// string list functions
// ----------------------------------------------------------------------------
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
return m_strings.GetCount() ;
}
void wxChoice::SetString( int n, const wxString& s )
{
- wxCHECK_RET( n >= 0 && (size_t)n < m_strings.GetCount(),
- wxT("wxChoice::SetString(): invalid index") );
+ wxCHECK_RET( IsValid(n), wxT("wxChoice::SetString(): invalid index") );
m_strings[n] = s ;
wxString wxChoice::GetString( int n ) const
{
- wxCHECK_MSG( n >= 0 && (size_t)n < m_strings.GetCount(), wxEmptyString,
- wxT("wxChoice::GetString(): invalid index") );
+ wxCHECK_MSG( IsValid(n), wxEmptyString, wxT("wxChoice::GetString(): invalid index") );
return m_strings[n] ;
}
// ----------------------------------------------------------------------------
void wxChoice::DoSetItemClientData( int n, void* clientData )
{
- wxCHECK_RET( n >= 0 && (size_t)n < m_datas.GetCount(),
- wxT("wxChoice::DoSetItemClientData: invalid index") );
+ wxCHECK_RET( IsValid(n), wxT("wxChoice::DoSetItemClientData: invalid index") );
m_datas[n] = (char*)clientData ;
}
void * wxChoice::DoGetItemClientData( int n ) const
{
- wxCHECK_MSG( n >= 0 && (size_t)n < m_datas.GetCount(), NULL,
- wxT("wxChoice::DoGetClientData: invalid index") );
+ wxCHECK_MSG( IsValid(n), NULL, wxT("wxChoice::DoGetClientData: invalid index") );
return (void *)m_datas[n];
}
}
// Find the widest line
- for(int i = 0; i < GetCount(); i++)
+ for(size_t i = 0; i < GetCount(); i++)
{
wxString str( GetString( i ) );
wLine = bounds.h ;
#else
- wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+ wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
#endif
lbWidth = wxMax( lbWidth, wLine ) ;
return result;
}
-int wxComboBox::GetCount() const
+size_t wxComboBox::GetCount() const
{
return m_choice->GetCount() ;
}
{
wxListBox* list = wxDynamicCast( (wxObject*) ref , wxListBox ) ;
int i = itemID - 1 ;
- if (i >= 0 && i < list->GetCount() )
+ if (i >= 0 && i < (int)list->GetCount() )
{
bool trigger = false ;
wxCommandEvent event( wxEVT_COMMAND_LISTBOX_SELECTED, list->GetId() );
{
wxListBox* list = wxDynamicCast( (wxObject*) ref , wxListBox ) ;
int i = itemID - 1 ;
- if (i >= 0 && i < list->GetCount() )
+ if (i >= 0 && i < (int)list->GetCount() )
{
wxMacCFStringHolder cf( list->GetString( i ) , list->GetFont().GetEncoding() ) ;
verify_noerr( ::SetDataBrowserItemDataText( itemData , cf ) ) ;
{
if ( HasClientObjectData() )
{
- for ( size_t n = 0; n < (size_t)m_noItems; n++ )
+ for ( size_t n = 0; n < m_noItems; n++ )
{
delete GetClientObject( n );
}
void wxListBox::Delete(int n)
{
- wxCHECK_RET( n >= 0 && n < m_noItems,
+ wxCHECK_RET( IsValid(n),
wxT("invalid index in wxListBox::Delete") );
if ( HasClientObjectData() )
{
InvalidateBestSize();
- int index = m_noItems ;
+ size_t index = m_noItems ;
m_stringArray.Add( item ) ;
m_dataArray.Add( NULL );
m_noItems++;
void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData)
{
Clear() ;
- int n = choices.GetCount();
+ size_t n = choices.GetCount();
- for ( int i = 0 ; i < n ; ++i )
+ for ( size_t i = 0 ; i < n ; ++i )
{
if ( clientData )
Append( choices[i] , clientData[i] ) ;
{
if ( s.Right(1) == wxT("*") )
{
- wxString search = s.Left( s.Length() - 1 ) ;
- int len = search.Length() ;
+ wxString search = s.Left( s.length() - 1 ) ;
+ int len = search.length() ;
Str255 s1 , s2 ;
wxMacStringToPascal( search , s2 ) ;
- for ( int i = 0 ; i < m_noItems ; ++ i )
+ for ( size_t i = 0 ; i < m_noItems ; ++ i )
{
wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ;
if ( EqualString( s1 , s2 , bCase , false ) )
- return i ;
+ return (int)i;
}
- if ( s.Left(1) == wxT("*") && s.Length() > 1 )
+ if ( s.Left(1) == wxT("*") && s.length() > 1 )
{
wxString st = s ;
st.MakeLower() ;
- for ( int i = 0 ; i < m_noItems ; ++i )
+ for ( size_t i = 0 ; i < m_noItems ; ++i )
{
if ( GetString( i ).Lower().Matches(st) )
- return i ;
+ return (int)i ;
}
}
}
wxMacStringToPascal( s , s2 ) ;
- for ( int i = 0 ; i < m_noItems ; ++ i )
+ for ( size_t i = 0 ; i < m_noItems ; ++ i )
{
wxMacStringToPascal( m_stringArray[i] , s1 ) ;
if ( EqualString( s1 , s2 , bCase , false ) )
- return i ;
+ return (int)i ;
}
}
void wxListBox::DoSetSelection(int n, bool select)
{
- wxCHECK_RET( n == wxNOT_FOUND || (n >= 0 && n < m_noItems) ,
+ wxCHECK_RET( n == wxNOT_FOUND || IsValid(n) ,
wxT("invalid index in wxListBox::SetSelection") );
if ( n == wxNOT_FOUND )
bool wxListBox::IsSelected(int n) const
{
- wxCHECK_MSG( n >= 0 && n < m_noItems, false,
+ wxCHECK_MSG( IsValid(n), false,
wxT("invalid index in wxListBox::Selected") );
return MacIsSelected( n ) ;
void *wxListBox::DoGetItemClientData(int n) const
{
- wxCHECK_MSG( n >= 0 && n < m_noItems, NULL,
- wxT("invalid index in wxListBox::GetClientData"));
+ wxCHECK_MSG( IsValid(n), NULL, wxT("invalid index in wxListBox::GetClientData"));
+
+ wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) n , wxT("invalid client_data array") ) ;
return (void *)m_dataArray[n];
}
void wxListBox::DoSetItemClientData(int n, void *clientData)
{
- wxCHECK_RET( n >= 0 && n < m_noItems,
- wxT("invalid index in wxListBox::SetClientData") );
+ wxCHECK_RET( IsValid(n), wxT("invalid index in wxListBox::SetClientData") );
wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) n , wxT("invalid client_data array") ) ;
// Find string for position
wxString wxListBox::GetString(int n) const
{
- wxCHECK_MSG( n >= 0 && n < m_noItems, wxEmptyString,
+ wxCHECK_MSG( IsValid(n), wxEmptyString,
wxT("invalid index in wxListBox::GetString") );
return m_stringArray[n] ;
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
- wxCHECK_RET( pos >= 0 && pos <= m_noItems,
+ wxCHECK_RET( IsValidInsert(pos),
wxT("invalid index in wxListBox::InsertItems") );
InvalidateBestSize();
- int nItems = items.GetCount();
+ size_t nItems = items.GetCount();
- for ( int i = 0 ; i < nItems ; i++ )
+ for ( size_t i = 0 ; i < nItems ; i++ )
{
m_stringArray.Insert( items[i] , pos + i ) ;
m_dataArray.Insert( NULL , pos + i ) ;
}
// Find the widest line
- for (int i = 0; i < GetCount(); i++)
+ for (size_t i = 0; i < GetCount(); i++)
{
wxString str( GetString( i ) );
&baseline );
wLine = bounds.h ;
#else
- wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+ wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
#endif
lbWidth = wxMax( lbWidth, wLine );
return wxSize( lbWidth, lbHeight );
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
return m_noItems;
}
int wxListBox::MacGetSelection() const
{
- for ( int i = 0 ; i < GetCount() ; ++i )
+ for ( size_t i = 0 ; i < GetCount() ; ++i )
{
if ( m_peer->IsItemSelected( i + 1 ) )
return i ;
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------
int i;
- m_noItems = n;
+ m_noItems = (size_t)n;
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
//
bool wxRadioBox::Enable(bool enable)
{
- int i;
wxRadioButton *current;
if (!wxControl::Enable( enable ))
return false;
current = m_radioButtonCycle;
- for (i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
{
current->Enable( enable );
current = current->NextInCycle();
//
bool wxRadioBox::Show(bool show)
{
- int i;
wxRadioButton *current;
current = m_radioButtonCycle;
- for (i=0; i<m_noItems; i++)
+ for (size_t i=0; i<m_noItems; i++)
{
current->Show( show );
current = current->NextInCycle();
maxWidth = -1;
maxHeight = -1;
- for (i = 0 ; i < m_noItems; i++)
+ for (size_t i = 0 ; i < m_noItems; i++)
{
GetTextExtent( GetString( i ), &eachWidth[i], &eachHeight[i] );
eachWidth[i] = (int)(eachWidth[i] + RADIO_SIZE);
maxWidth = -1;
maxHeight = -1;
- for (int i = 0 ; i < m_noItems; i++)
+ for (size_t i = 0 ; i < m_noItems; i++)
{
GetTextExtent( GetString( i ), &eachWidth, &eachHeight, NULL, NULL, &font );
eachWidth = (int)(eachWidth + RADIO_SIZE);
return wxSize( totWidth, totHeight );
}
-#endif
+#endif // wxUSE_RADIOBOX
///////////////////////////////////////////////////////////////////////////////
-// Name: checklst.cpp
+// Name: src/mac/classic/checklst.cpp
// Purpose: implementation of wxCheckListBox class
// Author: Stefan Csomor
-// Modified by:
+// Modified by:
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
// headers & declarations
// ============================================================================
-#include "wx/defs.h"
+#include "wx/wxprec.h"
#if wxUSE_CHECKLISTBOX
list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) );
if ( list == NULL )
return ;
-
+
GrafPtr savePort;
GrafPtr grafPtr;
RgnHandle savedClipRegion;
SetPort((**listHandle).port);
grafPtr = (**listHandle).port ;
// typecast our refCon
-
+
// Calculate the cell rect.
-
+
switch( message ) {
case lInitMsg:
break;
// Save the current clip region, and set the clip region to the area we are about
// to draw.
-
+
savedClipRegion = NewRgn();
GetClip( savedClipRegion );
ClipRect( drawRect );
EraseRect( drawRect );
-
+
const wxFont& font = list->GetFont();
if ( font.Ok() )
{
::TextSize( font.GetMacFontSize()) ;
::TextFace( font.GetMacFontStyle() ) ;
}
-
+
ThemeButtonDrawInfo info ;
info.state = kThemeStateActive ;
info.value = checked ? kThemeButtonOn : kThemeButtonOff ;
info.adornment = kThemeAdornmentNone ;
Rect checkRect = *drawRect ;
-
-
+
+
checkRect.left +=0 ;
checkRect.top +=0 ;
checkRect.right = checkRect.left + list->m_checkBoxWidth ;
checkRect.bottom = checkRect.top + list->m_checkBoxHeight ;
DrawThemeButton(&checkRect,kThemeCheckBox,
&info,NULL,NULL, NULL,0);
-
+
MoveTo(drawRect->left + 2 + list->m_checkBoxWidth+2, drawRect->top + list->m_TextBaseLineOffset );
-
- DrawText(text, 0 , text.Length());
+
+ DrawText(text, 0 , text.length());
// If the cell is hilited, do the hilite now. Paint the cell contents with the
// appropriate QuickDraw transform mode.
-
+
if( isSelected ) {
savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
PaintRect( drawRect );
SetPortPenMode( (CGrafPtr) grafPtr, savedPenMode );
}
-
+
// Restore the saved clip region.
-
+
SetClip( savedClipRegion );
DisposeRgn( savedClipRegion );
}
break;
case lHiliteMsg:
-
+
// Hilite or unhilite the cell. Paint the cell contents with the
// appropriate QuickDraw transform mode.
-
+
GetPort( &grafPtr );
savedPenMode = GetPortPenMode( (CGrafPtr) grafPtr );
SetPortPenMode( (CGrafPtr) grafPtr, hilitetransfermode );
default :
break ;
}
- SetPort(savePort);
+ SetPort(savePort);
}
extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ;
m_noItems = 0 ; // this will be increased by our append command
m_selected = 0;
-
+
m_checkBoxWidth = 12;
m_checkBoxHeight= 10;
-
+
long h = m_checkBoxHeight ;
#if TARGET_CARBON
- GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth);
+ GetThemeMetric(kThemeMetricCheckBoxWidth,(long *)&m_checkBoxWidth);
GetThemeMetric(kThemeMetricCheckBoxHeight,&h);
#endif
FontInfo finfo;
FetchFontInfo(font.GetMacFontNum(),font.GetMacFontSize(),font.GetMacFontStyle(),&finfo);
-
+
m_TextBaseLineOffset= finfo.leading+finfo.ascent;
m_checkBoxHeight= finfo.leading+finfo.ascent+finfo.descent;
-
+
if (m_checkBoxHeight<h)
{
m_TextBaseLineOffset+= (h-m_checkBoxHeight)/2;
m_checkBoxHeight= h;
}
-
+
Rect bounds ;
Str255 title ;
-
+
MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
ListDefSpec listDef;
listDef.defType = kListDefUserProcType;
if ( macCheckListDefUPP == NULL )
{
- macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition );
+ macCheckListDefUPP = NewListDefUPP( wxMacCheckListDefinition );
}
listDef.u.userProc = macCheckListDefUPP ;
wxStAppResource resload ;
m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false ,
- kwxMacListWithVerticalScrollbar , 0 , 0,
+ kwxMacListWithVerticalScrollbar , 0 , 0,
kControlListBoxProc , (long) this ) ;
::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag ,
sizeof( ListHandle ) , (char*) &m_macList , &result ) ;
(**ldef).function = (void(*)()) listDef.u.userProc;
(**(ListHandle)m_macList).listDefProc = (Handle) ldef ;
}
-
+
Point pt = (**(ListHandle)m_macList).cellSize ;
pt.v = 14 ;
LCellSize( pt , (ListHandle)m_macList ) ;
options = (OptionBits) lOnlyOne ;
}
SetListSelectionFlags((ListHandle)m_macList, options);
-
+
MacPostControlCreate() ;
-
+
for ( int i = 0 ; i < n ; i++ )
{
Append( choices[i] ) ;
}
-
+
LSetDrawingMode( true , (ListHandle) m_macList ) ;
- return TRUE;
+ return true;
}
// ----------------------------------------------------------------------------
bool wxCheckListBox::IsChecked(size_t item) const
{
- wxCHECK_MSG( item < m_checks.GetCount(), FALSE,
+ wxCHECK_MSG( IsValid(item), false,
_T("invalid index in wxCheckListBox::IsChecked") );
return m_checks[item] != 0;
void wxCheckListBox::Check(size_t item, bool check)
{
- wxCHECK_RET( item < m_checks.GetCount(),
+ wxCHECK_RET( IsValid(item),
_T("invalid index in wxCheckListBox::Check") );
// intermediate var is needed to avoid compiler warning with VC++
void wxCheckListBox::Delete(int n)
{
- wxCHECK_RET( n < GetCount(), _T("invalid index in wxListBox::Delete") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxListBox::Delete") );
wxListBox::Delete(n);
int pos = wxListBox::DoAppend(item);
// the item is initially unchecked
- m_checks.Insert(FALSE, pos);
+ m_checks.Insert(false, pos);
LSetDrawingMode( true , (ListHandle) m_macList ) ;
return pos;
size_t count = items.GetCount();
for ( size_t n = 0; n < count; n++ )
{
- m_checks.Insert(FALSE, pos + n);
+ m_checks.Insert(false, pos + n);
}
}
size_t count = items.GetCount();
for ( size_t n = 0; n < count; n++ )
{
- m_checks.Add(FALSE);
+ m_checks.Add(false);
}
}
EVT_LEFT_DOWN(wxCheckListBox::OnLeftClick)
END_EVENT_TABLE()
-// this will only work as soon as
+// this will only work as soon as
void wxCheckListBox::OnChar(wxKeyEvent& event)
{
topcell = (**(ListHandle)m_macList).visible.top ;
#endif
size_t nItem = ((size_t)event.GetY()) / lineheight + topcell ;
-
- if ( nItem < (size_t)m_noItems )
+
+ if ( nItem < m_noItems )
{
Check(nItem, !IsChecked(nItem) ) ;
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#include "wx/defs.h"
+#include "wx/wxprec.h"
#if wxUSE_CHOICE
int wxChoice::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+ wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
if (pos == GetCount())
return DoAppend(item);
void wxChoice::Delete(int n)
{
- wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
+ wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") );
if ( HasClientObjectData() )
{
delete GetClientObject(n);
// string list functions
// ----------------------------------------------------------------------------
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
return m_strings.GetCount() ;
}
wxString wxChoice::GetString(int n) const
{
- wxCHECK_MSG( n >= 0 && (size_t)n < m_strings.GetCount(), wxEmptyString,
+ wxCHECK_MSG( IsValid(n), wxEmptyString,
_T("wxChoice::GetString(): invalid index") );
return m_strings[n] ;
&baseline );
wLine = bounds.h ;
#else
- wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+ wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
#endif
lbWidth = wxMax(lbWidth, wLine);
}
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
+#include "wx/wxprec.h"
+
+#if wxUSE_LISTBOX
+
#include "wx/app.h"
#include "wx/listbox.h"
#include "wx/button.h"
LSetDrawingMode( true , (ListHandle)m_macList ) ;
- return TRUE;
+ return true;
}
wxListBox::~wxListBox()
#endif // wxUSE_OWNER_DRAWN
if ( HasClientObjectData() )
{
- for ( size_t n = 0; n < (size_t)m_noItems; n++ )
+ for ( size_t n = 0; n < m_noItems; n++ )
{
delete GetClientObject(n);
}
void wxListBox::Delete(int N)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::Delete") );
#if wxUSE_OWNER_DRAWN
{
InvalidateBestSize();
- int index = m_noItems ;
+ size_t index = m_noItems ;
m_stringArray.Add( item ) ;
m_dataArray.Add( NULL );
m_noItems ++;
m_aItems.Empty();
// then create new ones
- for ( ui = 0; ui < (size_t)m_noItems; ui++ ) {
+ for ( ui = 0; ui < m_noItems; ui++ ) {
wxOwnerDrawn *pNewItem = CreateItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
{
if ( s.Right(1) == wxT("*") )
{
- wxString search = s.Left( s.Length() - 1 ) ;
- int len = search.Length() ;
+ wxString search = s.Left( s.length() - 1 ) ;
+ int len = search.length() ;
Str255 s1 , s2 ;
wxMacStringToPascal( search , s2 ) ;
- for ( int i = 0 ; i < m_noItems ; ++ i )
+ for ( size_t i = 0 ; i < m_noItems ; ++ i )
{
wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ;
if ( EqualString( s1 , s2 , bCase , false ) )
- return i ;
+ return (int)i ;
}
- if ( s.Left(1) == wxT("*") && s.Length() > 1 )
+ if ( s.Left(1) == wxT("*") && s.length() > 1 )
{
wxString st = s ;
st.MakeLower() ;
- for ( int i = 0 ; i < m_noItems ; ++i )
+ for ( size_t i = 0 ; i < m_noItems ; ++i )
{
if ( GetString(i).Lower().Matches(st) )
- return i ;
+ return (int)i ;
}
}
wxMacStringToPascal( s , s2 ) ;
- for ( int i = 0 ; i < m_noItems ; ++ i )
+ for ( size_t i = 0 ; i < m_noItems ; ++ i )
{
wxMacStringToPascal( m_stringArray[i] , s1 ) ;
if ( EqualString( s1 , s2 , bCase , false ) )
- return i ;
+ return (int)i ;
}
}
void wxListBox::DoSetSelection(int N, bool select)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetSelection") );
MacSetSelection( N , select ) ;
GetSelections( m_selectionPreImage ) ;
bool wxListBox::IsSelected(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
+ wxCHECK_MSG( IsValid(N), false,
wxT("invalid index in wxListBox::Selected") );
return MacIsSelected( N ) ;
void *wxListBox::DoGetItemClientData(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, NULL,
+ wxCHECK_MSG( IsValid(N), NULL,
wxT("invalid index in wxListBox::GetClientData"));
return (void *)m_dataArray[N];
void wxListBox::DoSetItemClientData(int N, void *Client_data)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetClientData") );
#if wxUSE_OWNER_DRAWN
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
- wxCHECK_RET( pos >= 0 && pos <= m_noItems,
+ wxCHECK_RET( IsValidInsert(pos),
wxT("invalid index in wxListBox::InsertItems") );
InvalidateBestSize();
- int nItems = items.GetCount();
+ size_t nItems = items.GetCount();
- for ( int i = 0 ; i < nItems ; i++ )
+ for ( size_t i = 0 ; i < nItems ; i++ )
{
m_stringArray.Insert( items[i] , pos + i ) ;
m_dataArray.Insert( NULL , pos + i ) ;
&baseline );
wLine = bounds.h ;
#else
- wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+ wLine = ::TextWidth( str.c_str() , 0 , str.length() ) ;
#endif
lbWidth = wxMax(lbWidth, wLine);
}
return wxSize(lbWidth, lbHeight);
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
return m_noItems;
}
wxListBoxItem(const wxString& str = wxEmptyString);
};
-wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
+wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, false)
{
// no bitmaps/checkmarks
SetMarginWidth(0);
::TextFont( kFontIDMonaco ) ;
::TextSize( 9 );
::TextFace( 0 ) ;
- DrawText(text, 0 , text.Length());
+ DrawText(text, 0 , text.length());
}
*/
}
}
}
+
+#endif // wxUSE_LISTBOX
// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWindows licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//-------------------------------------------------------------------------------------
// headers
//-------------------------------------------------------------------------------------
-#include "wx/defs.h"
-#include "wx/arrstr.h"
+#include "wx/wxprec.h"
+
+#if wxUSE_RADIOBOX
+#include "wx/arrstr.h"
#include "wx/radiobox.h"
#include "wx/radiobut.h"
#include "wx/mac/uma.h"
int i;
- m_noItems = n;
+ m_noItems = (size_t)n;
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
bool wxRadioBox::Enable(bool enable)
{
- int i;
wxRadioButton *current;
if (!wxControl::Enable(enable))
return false;
current = m_radioButtonCycle;
- for (i = 0; i < m_noItems; i++) {
+ for (size_t i = 0; i < m_noItems; i++) {
current->Enable(enable);
current = current->NextInCycle();
}
bool wxRadioBox::Show(bool show)
{
- int i;
wxRadioButton *current;
wxControl::Show(show);
current=m_radioButtonCycle;
- for (i=0;i<m_noItems;i++)
+ for (size_t i=0; i<m_noItems; i++)
{
current->Show(show);
current=current->NextInCycle();
void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
- int i;
+ size_t i;
wxRadioButton *current;
// define the position
eachHeight[i] = (int)((3*eachHeight[i])/2);
if (maxWidth<eachWidth[i]) maxWidth = eachWidth[i];
if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
- }
+ }
totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth;
maxWidth = -1;
maxHeight = -1;
- for (int i = 0 ; i < m_noItems; i++)
+ for (size_t i = 0 ; i < m_noItems; i++)
{
GetTextExtent(GetString(i), &eachWidth, &eachHeight);
eachWidth = (int)(eachWidth + RADIO_SIZE) ;
return wxSize(totWidth, totHeight);
}
+
+#endif // wxUSE_RADIOBOX
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxUSE_CHOICE
+
#ifdef __VMS
#define XtDisplay XTDISPLAY
#define XtParent XTPARENT
#endif
-#include "wx/defs.h"
-
-#if wxUSE_CHOICE
-
#include "wx/choice.h"
#include "wx/utils.h"
#include "wx/arrstr.h"
int wxChoice::DoInsert(const wxString& item, int pos)
{
#ifndef XmNpositionIndex
- wxCHECK_MSG( pos == GetCount(), -1, wxT("insert not implemented"));
+ wxCHECK_MSG( (size_t)pos == GetCount(), -1, wxT("insert not implemented"));
#endif
Widget w = XtVaCreateManagedWidget (wxStripMenuCodes(item),
#if wxUSE_GADGETS
int wxChoice::DoAppend(const wxString& item)
{
- return DoInsert(item, GetCount());
+ return DoInsert(item, (int)GetCount());
}
void wxChoice::Delete(int n)
wxDoChangeForegroundColour(m_widgetArray[i], m_foregroundColour);
}
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
return m_noStrings;
}
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
- m_noStrings = n;
+ m_noStrings = (size_t)n;
Widget parentWidget = (Widget) parent->GetClientWidget();
int wxComboBox::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+ wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
if (pos == GetCount())
return DoAppend(item);
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxUSE_LISTBOX
+
#ifdef __VMS
#define XtParent XTPARENT
#define XtDisplay XTDISPLAY
validator, name ) )
return false;
- m_noItems = n;
+ m_noItems = (size_t)n;
m_backgroundColour = * wxWHITE;
Widget parentWidget = (Widget) parent->GetClientWidget();
{
int count, length;
- if (N < 0)
+ if (!IsValid(N))
return;
+
XtVaGetValues ((Widget) m_mainWidget,
XmNvisibleItemCount, &count,
XmNitemCount, &length,
*/
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
return m_noItems;
}
{
return wxDoGetListBoxBestSize( (Widget)m_mainWidget, this );
}
+
+#endif // wxUSE_LISTBOX
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxUSE_RADIOBOX
+
#ifdef __VMS
#define XtDisplay XTDISPLAY
#endif
-#include "wx/defs.h"
-
#include "wx/radiobox.h"
#include "wx/utils.h"
#include "wx/arrstr.h"
if( !CreateControl( parent, id, pos, size, style, val, name ) )
return false;
- m_noItems = n;
+ m_noItems = (size_t)n;
m_noRowsOrCols = majorDim;
SetMajorDim(majorDim == 0 ? n : majorDim, style);
XmToggleButtonSetState ((Widget) m_radioButtons[n], True, False);
- int i;
- for (i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
if (i != n)
XmToggleButtonSetState ((Widget) m_radioButtons[i], False, False);
if ( !wxControl::Enable(enable) )
return false;
- int i;
- for (i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
XtSetSensitive ((Widget) m_radioButtons[i], (Boolean) enable);
return true;
{
wxWindow::ChangeFont(keepOriginalSize);
- int i;
- for (i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
{
WXWidget radioButton = m_radioButtons[i];
int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
- int i;
- for (i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
{
WXWidget radioButton = m_radioButtons[i];
{
wxWindow::ChangeForegroundColour();
- int i;
- for (i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
{
WXWidget radioButton = m_radioButtons[i];
event.SetEventObject(item);
item->ProcessCommand (event);
}
+
+#endif // wxUSE_RADIOBOX
///////////////////////////////////////////////////////////////////////////////
-// Name: msw/checklst.cpp
+// Name: src/msw/checklst.cpp
// Purpose: implementation of wxCheckListBox class
// Author: Vadim Zeitlin
// Modified by:
void wxCheckListBox::Delete(int N)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::Delete") );
wxListBox::Delete(N);
MAKELPARAM(x, y)
);
- return nItem >= m_noItems ? wxNOT_FOUND : nItem;
+ return nItem >= (int)m_noItems ? wxNOT_FOUND : nItem;
}
}
#endif
-
int wxChoice::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+ wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
int n = (int)SendMessage(GetHwnd(), CB_INSERTSTRING, pos, (LPARAM)item.c_str());
if ( n == CB_ERR )
void wxChoice::Delete(int n)
{
- wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
+ wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") );
if ( HasClientObjectData() )
{
// string list functions
// ----------------------------------------------------------------------------
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
- return (int)SendMessage(GetHwnd(), CB_GETCOUNT, 0, 0);
+ return (size_t)SendMessage(GetHwnd(), CB_GETCOUNT, 0, 0);
}
int wxChoice::FindString(const wxString& s, bool bCase) const
#if defined(__WATCOMC__) && defined(__WIN386__)
// For some reason, Watcom in WIN386 mode crashes in the CB_FINDSTRINGEXACT message.
// wxChoice::Do it the long way instead.
- int count = GetCount();
- for ( int i = 0; i < count; i++ )
+ size_t count = GetCount();
+ for ( size_t i = 0; i < count; i++ )
{
// as CB_FINDSTRINGEXACT is case insensitive, be case insensitive too
if ( GetString(i).IsSameAs(s, bCase) )
//passed to SendMessage, so we have to do it ourselves in that case
if ( s.empty() )
{
- int count = GetCount();
- for ( int i = 0; i < count; i++ )
+ size_t count = GetCount();
+ for ( size_t i = 0; i < count; i++ )
{
if ( GetString(i).empty() )
return i;
void wxChoice::SetString(int n, const wxString& s)
{
- wxCHECK_RET( n >= 0 && n < GetCount(),
- wxT("invalid item index in wxChoice::SetString") );
+ wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::SetString") );
// we have to delete and add back the string as there is no way to change a
// string in place
void wxListBox::DoSetFirstItem(int N)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetFirstItem") );
SendMessage(GetHwnd(), LB_SETTOPINDEX, (WPARAM)N, (LPARAM)0);
void wxListBox::Delete(int N)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::Delete") );
// for owner drawn objects, the data is used for storing wxOwnerDrawn
ListBox_ResetContent(GetHwnd());
m_noItems = choices.GetCount();
- int i;
+ size_t i;
for (i = 0; i < m_noItems; i++)
{
ListBox_AddString(GetHwnd(), choices[i]);
WX_CLEAR_ARRAY(m_aItems);
// then create new ones
- for ( size_t ui = 0; ui < (size_t)m_noItems; ui++ ) {
+ for ( size_t ui = 0; ui < m_noItems; ui++ ) {
wxOwnerDrawn *pNewItem = CreateLboxItem(ui);
pNewItem->SetName(choices[ui]);
m_aItems.Add(pNewItem);
#endif // wxUSE_OWNER_DRAWN
if ( HasClientObjectData() )
{
- for ( size_t n = 0; n < (size_t)m_noItems; n++ )
+ for ( size_t n = 0; n < m_noItems; n++ )
{
delete GetClientObject(n);
}
void wxListBox::DoSetSelection(int N, bool select)
{
- wxCHECK_RET( N == wxNOT_FOUND ||
- (N >= 0 && N < m_noItems),
+ wxCHECK_RET( N == wxNOT_FOUND || IsValid(N),
wxT("invalid index in wxListBox::SetSelection") );
if ( HasMultipleSelection() )
bool wxListBox::IsSelected(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, false,
+ wxCHECK_MSG( IsValid(N), false,
wxT("invalid index in wxListBox::Selected") );
return SendMessage(GetHwnd(), LB_GETSEL, N, 0) == 0 ? false : true;
void *wxListBox::DoGetItemClientData(int n) const
{
- wxCHECK_MSG( n >= 0 && n < m_noItems, NULL,
+ wxCHECK_MSG( IsValid(n), NULL,
wxT("invalid index in wxListBox::GetClientData") );
return (void *)SendMessage(GetHwnd(), LB_GETITEMDATA, n, 0);
void wxListBox::DoSetItemClientData(int n, void *clientData)
{
- wxCHECK_RET( n >= 0 && n < m_noItems,
+ wxCHECK_RET( IsValid(n),
wxT("invalid index in wxListBox::SetClientData") );
#if wxUSE_OWNER_DRAWN
// Find string for position
wxString wxListBox::GetString(int N) const
{
- wxCHECK_MSG( N >= 0 && N < m_noItems, wxEmptyString,
+ wxCHECK_MSG( IsValid(N), wxEmptyString,
wxT("invalid index in wxListBox::GetString") );
int len = ListBox_GetTextLen(GetHwnd(), N);
void
wxListBox::DoInsertItems(const wxArrayString& items, int pos)
{
- wxCHECK_RET( pos >= 0 && pos <= m_noItems,
+ wxCHECK_RET( IsValidInsert(pos),
wxT("invalid index in wxListBox::InsertItems") );
int nItems = items.GetCount();
int wxListBox::DoListHitTest(const wxPoint& point) const
{
- LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
+ LRESULT lRes = ::SendMessage(GetHwnd(), LB_ITEMFROMPOINT,
0L, MAKELONG(point.x, point.y));
// non zero high-order word means that this item is outside of the client
void wxListBox::SetString(int N, const wxString& s)
{
- wxCHECK_RET( N >= 0 && N < m_noItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetString") );
// remember the state of the item
SendMessage(GetHwnd(), LB_DELETESTRING, N, 0);
int newN = N;
- if ( N == m_noItems - 1 )
+ if ( N == (int)(m_noItems - 1) )
newN = -1;
ListBox_InsertString(GetHwnd(), newN, s);
InvalidateBestSize();
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
return m_noItems;
}
GetTextMetrics(dc, &lpTextMetric);
SIZE extentXY;
- ::GetTextExtentPoint32(dc, (LPTSTR) (const wxChar *)s, s.Length(), &extentXY);
+ ::GetTextExtentPoint32(dc, (LPTSTR) (const wxChar *)s, s.length(), &extentXY);
int extentX = (int)(extentXY.cx + lpTextMetric.tmAveCharWidth);
if (oldFont)
GetTextMetrics(dc, &lpTextMetric);
- for (int i = 0; i < m_noItems; i++)
+ for (size_t i = 0; i < m_noItems; i++)
{
wxString str = GetString(i);
SIZE extentXY;
// find the widest string
int wLine;
int wListbox = 0;
- for ( int i = 0; i < m_noItems; i++ )
+ for ( size_t i = 0; i < m_noItems; i++ )
{
wxString str(GetString(i));
GetTextExtent(str, &wLine, NULL);
int selectedButton = wxNOT_FOUND;
- int count = GetCount();
- for ( int i = 0; i < count; i++ )
+ const size_t count = GetCount();
+ for ( size_t i = 0; i < count; i++ )
{
if ( id == wxGetWindowId((*m_radioButtons)[i]) )
{
// simple accessors
// ----------------------------------------------------------------------------
-int wxRadioBox::GetCount() const
+size_t wxRadioBox::GetCount() const
{
return m_radioButtons->GetCount();
}
// calculate the max button size
int widthMax = 0,
heightMax = 0;
- const int count = GetCount();
- for ( int i = 0 ; i < count; i++ )
+ const size_t count = GetCount();
+ for ( size_t i = 0 ; i < count; i++ )
{
int width, height;
if ( m_radioWidth[i] < 0 )
int startX = x_offset;
int startY = y_offset;
- const int count = GetCount();
- for ( int i = 0; i < count; i++ )
+ const size_t count = GetCount();
+ for ( size_t i = 0; i < count; i++ )
{
// the last button in the row may be wider than the other ones as the
// radiobox may be wider than the sum of the button widths (as it
{
// item is the last in its row if it is a multiple of the number of
// columns or if it is just the last item
- int n = i + 1;
+ size_t n = i + 1;
isLastInTheRow = ((n % GetMajorDim()) == 0) || (n == count);
}
else // wxRA_SPECIFY_ROWS
void wxCheckListBox::Delete(int n)
{
- wxCHECK_RET( n >= 0 && n < GetCount(),
- _T("invalid index in wxCheckListBox::Delete") );
+ wxCHECK_RET( IsValid( n ), _T("invalid index in wxCheckListBox::Delete") );
if ( !ListView_DeleteItem(GetHwnd(), n) )
{
bool wxCheckListBox::IsChecked(size_t uiIndex) const
{
- wxCHECK_MSG( uiIndex < (size_t)GetCount(), false,
+ wxCHECK_MSG( IsValid( uiIndex ), false,
_T("invalid index in wxCheckListBox::IsChecked") );
return (ListView_GetCheckState(((HWND)GetHWND()), uiIndex) != 0);
void wxCheckListBox::Check(size_t uiIndex, bool bCheck)
{
- wxCHECK_RET( uiIndex < (size_t)GetCount(),
+ wxCHECK_RET( IsValid( uiIndex ),
_T("invalid index in wxCheckListBox::Check") );
ListView_SetCheckState(((HWND)GetHWND()), uiIndex, bCheck)
void wxCheckListBox::Clear()
{
- int n = GetCount();
+ int n = (int)GetCount();
while ( n > 0 )
{
_T("broken wxCheckListBox::Clear()") );
}
-int wxCheckListBox::GetCount() const
+size_t wxCheckListBox::GetCount() const
{
- return ListView_GetItemCount( (HWND)GetHWND() );
+ return (size_t)ListView_GetItemCount( (HWND)GetHWND() );
}
int wxCheckListBox::GetSelection() const
{
int i;
- for (i = 0; i < GetCount(); i++)
+ for (i = 0; (size_t)i < GetCount(); i++)
{
int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED);
if (selState == LVIS_SELECTED)
int wxCheckListBox::GetSelections(wxArrayInt& aSelections) const
{
int i;
- for (i = 0; i < GetCount(); i++)
+ for (i = 0; (size_t)i < GetCount(); i++)
{
int selState = ListView_GetItemState(GetHwnd(), i, LVIS_SELECTED);
if (selState == LVIS_SELECTED)
void wxCheckListBox::SetString(int n, const wxString& s)
{
- wxCHECK_RET( n < GetCount(),
+ wxCHECK_RET( IsValid( n ),
_T("invalid index in wxCheckListBox::SetString") );
wxChar *buf = new wxChar[s.length()+1];
wxStrcpy(buf, s.c_str());
int wxCheckListBox::DoAppend(const wxString& item)
{
- int n = GetCount();
+ int n = (int)GetCount();
LVITEM newItem;
wxZeroMemory(newItem);
newItem.iItem = n;
void wxCheckListBox::DoInsertItems(const wxArrayString& items, int pos)
{
- wxCHECK_RET( pos >= 0 && pos <= GetCount(),
+ wxCHECK_RET( IsValidInsert( pos ),
wxT("invalid index in wxListBox::InsertItems") );
for( size_t i = 0; i < items.GetCount(); i++ )
#pragma hdrstop
#endif
+#if wxUSE_CHOICE && defined(__SMARTPHONE__) && defined(__WXWINCE__)
+
#ifndef WX_PRECOMP
#include "wx/choice.h"
+ #include <commctrl.h>
+ #include "wx/msw/missing.h"
+ #include "wx/msw/winundef.h"
#endif
#include "wx/spinbutt.h" // for wxSpinnerBestSize
-#include <commctrl.h>
-#include "wx/msw/missing.h"
-#include "wx/msw/winundef.h"
-
-#if wxUSE_CHOICE && defined(__SMARTPHONE__) && defined(__WXWINCE__)
-
#if wxUSE_EXTENDED_RTTI
// TODO
#else
int wxChoice::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into choice"));
- wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+ wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index"));
int n = (int)::SendMessage(GetBuddyHwnd(), LB_INSERTSTRING, pos, (LPARAM)item.c_str());
if ( n == LB_ERR )
void wxChoice::Delete(int n)
{
- wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
+ wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") );
if ( HasClientObjectData() )
{
// string list functions
// ----------------------------------------------------------------------------
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
- return (int)::SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0);
+ return (size_t)::SendMessage(GetBuddyHwnd(), LB_GETCOUNT, 0, 0);
}
int wxChoice::FindString(const wxString& s, bool bCase) const
void wxChoice::SetString(int n, const wxString& s)
{
- wxCHECK_RET( n >= 0 && n < GetCount(),
+ wxCHECK_RET( IsValid(n),
wxT("invalid item index in wxChoice::SetString") );
// we have to delete and add back the string as there is no way to change a
void wxCheckListBox::Delete( int n )
{
- wxCHECK_RET( n >= 0 && n < m_nNumItems,
+ wxCHECK_RET( IsValid(n),
wxT("invalid index in wxCheckListBox::Delete") );
wxListBox::Delete(n);
size_t nItem = (size_t)(nY / vHeight);
- if (nItem < (size_t)m_nNumItems)
+ if (nItem < m_nNumItems)
GetItem(nItem)->Toggle();
//
// else: it's not an error, just click outside of client zone
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
-#include "wx/defs.h"
-
#if wxUSE_CHOICE
#ifndef WX_PRECOMP
return nIndex;
} // end of wxChoice::DoAppend
-int wxChoice::DoInsert(
- const wxString& rsItem,
- int pos
-)
+int wxChoice::DoInsert( const wxString& rsItem, int pos )
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- 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(rsItem);
- int nIndex;
- LONG nIndexType = 0;
+ int nIndex;
+ LONG nIndexType = 0;
if (m_windowStyle & wxLB_SORT)
nIndexType = LIT_SORTASCENDING;
return nIndex;
} // end of wxChoice::DoInsert
-void wxChoice::Delete(
- int n
-)
+void wxChoice::Delete( int n )
{
- wxCHECK_RET( n < GetCount(), wxT("invalid item index in wxChoice::Delete") );
+ wxCHECK_RET( IsValid(n), wxT("invalid item index in wxChoice::Delete") );
::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)n, (MPARAM)0);
} // end of wxChoice::Delete
// string list functions
// ----------------------------------------------------------------------------
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
- return((int)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMCOUNT, (MPARAM)0, (MPARAM)0)));
+ return((size_t)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMCOUNT, (MPARAM)0, (MPARAM)0)));
} // end of wxChoice::GetCount
void wxChoice::SetString( int n, const wxString& rsStr )
//
// Find the widest string
//
- int nLineWidth;
- int nChoiceWidth = 0;
- int nItems = GetCount();
- int nCx;
- int nCy;
- wxFont vFont = (wxFont)GetFont();
-
- for (int i = 0; i < nItems; i++)
- {
- wxString sStr(GetString(i));
+ int nLineWidth;
+ int nChoiceWidth = 0;
+ int nCx;
+ int nCy;
+ wxFont vFont = (wxFont)GetFont();
+
+ const size_t nItems = GetCount();
- GetTextExtent( sStr
- ,&nLineWidth
- ,NULL
- );
+ for (size_t i = 0; i < nItems; i++)
+ {
+ wxString sStr(GetString(i));
+ GetTextExtent( sStr, &nLineWidth, NULL );
if (nLineWidth > nChoiceWidth)
nChoiceWidth = nLineWidth;
}
//
// The combobox should be larger than the widest string
//
- wxGetCharSize( GetHWND()
- ,&nCx
- ,&nCy
- ,&vFont
- );
+ wxGetCharSize( GetHWND(), &nCx, &nCy, &vFont );
nChoiceWidth += 5 * nCx;
//
{
if (HasClientObjectData())
{
- size_t nCount = GetCount();
+ const size_t nCount = GetCount();
for (size_t n = 0; n < nCount; n++)
{
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxUSE_LISTBOX
+
#include "wx/window.h"
#include "wx/os2/private.h"
#include "wx/dynarray.h"
#include "wx/log.h"
-#if wxUSE_LISTBOX
-
#if wxUSE_OWNER_DRAWN
#include "wx/ownerdrw.h"
#endif
lStyle, rValidator, rsName);
}
-bool wxListBox::Create(
- wxWindow* pParent
-, wxWindowID vId
-, const wxPoint& rPos
-, const wxSize& rSize
-, int n
-, const wxString asChoices[]
-, long lStyle
-, const wxValidator& rValidator
-, const wxString& rsName
-)
+bool wxListBox::Create( wxWindow* pParent,
+ wxWindowID vId,
+ const wxPoint& rPos,
+ const wxSize& rSize,
+ int n,
+ const wxString asChoices[],
+ long lStyle,
+ const wxValidator& rValidator,
+ const wxString& rsName )
{
m_nNumItems = 0;
m_hWnd = 0;
wxListBox::~wxListBox()
{
#if wxUSE_OWNER_DRAWN
- size_t lUiCount = m_aItems.Count();
+ size_t lUiCount = m_aItems.Count();
while (lUiCount-- != 0)
{
// implementation of wxListBoxBase methods
// ----------------------------------------------------------------------------
-void wxListBox::DoSetFirstItem(
- int N
-)
+void wxListBox::DoSetFirstItem(int N)
{
- wxCHECK_RET( N >= 0 && N < m_nNumItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetFirstItem") );
::WinSendMsg(GetHwnd(), LM_SETTOPINDEX, MPFROMLONG(N), (MPARAM)0);
} // end of wxListBox::DoSetFirstItem
-void wxListBox::Delete(
- int N
-)
+void wxListBox::Delete(int N)
{
- wxCHECK_RET( N >= 0 && N < m_nNumItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::Delete") );
#if wxUSE_OWNER_DRAWN
m_nNumItems--;
} // end of wxListBox::DoSetFirstItem
-int wxListBox::DoAppend(
- const wxString& rsItem
-)
+int wxListBox::DoAppend(const wxString& rsItem)
{
- long lIndex = 0;
- LONG lIndexType = 0;
+ long lIndex = 0;
+ LONG lIndexType = 0;
if (m_windowStyle & wxLB_SORT)
lIndexType = LIT_SORTASCENDING;
else
lIndexType = LIT_END;
+
lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.c_str());
m_nNumItems++;
return (int)lIndex;
} // end of wxListBox::DoAppend
-void wxListBox::DoSetItems(
- const wxArrayString& raChoices
-, void** ppClientData
-)
+void wxListBox::DoSetItems( const wxArrayString& raChoices,
+ void** ppClientData )
{
- BOOL bHideAndShow = IsShown();
- int i;
- LONG lIndexType = 0;
+ BOOL bHideAndShow = IsShown();
+ LONG lIndexType = 0;
if (bHideAndShow)
{
}
::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
m_nNumItems = raChoices.GetCount();
- for (i = 0; i < m_nNumItems; i++)
+ for (size_t i = 0; i < m_nNumItems; i++)
{
-
if (m_windowStyle & wxLB_SORT)
lIndexType = LIT_SORTASCENDING;
else
//
// Then create new ones
//
- for (size_t ui = 0; ui < (size_t)m_nNumItems; ui++)
+ for (size_t ui = 0; ui < m_nNumItems; ui++)
{
wxOwnerDrawn* pNewItem = CreateItem(ui);
void wxListBox::Clear()
{
#if wxUSE_OWNER_DRAWN
- size_t lUiCount = m_aItems.Count();
+ size_t lUiCount = m_aItems.Count();
while (lUiCount-- != 0)
{
m_nNumItems = 0;
} // end of wxListBox::Clear
-void wxListBox::DoSetSelection(
- int N
-, bool bSelect
-)
+void wxListBox::DoSetSelection( int N, bool bSelect)
{
- wxCHECK_RET( N >= 0 && N < m_nNumItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetSelection") );
::WinSendMsg( GetHwnd()
,LM_SELECTITEM
Refresh();
} // end of wxListBox::SetSelection
-bool wxListBox::IsSelected(
- int N
-) const
+bool wxListBox::IsSelected( int N ) const
{
- wxCHECK_MSG( N >= 0 && N < m_nNumItems, false,
+ wxCHECK_MSG( IsValid(N), false,
wxT("invalid index in wxListBox::Selected") );
LONG lItem;
return (lItem == (LONG)N && lItem != LIT_NONE);
} // end of wxListBox::IsSelected
-wxClientData* wxListBox::DoGetItemClientObject(
- int n
-) const
+wxClientData* wxListBox::DoGetItemClientObject(int n) const
{
return (wxClientData *)DoGetItemClientData(n);
}
-void* wxListBox::DoGetItemClientData(
- int n
-) const
+void* wxListBox::DoGetItemClientData(int n) const
{
- wxCHECK_MSG( n >= 0 && n < m_nNumItems, NULL,
+ wxCHECK_MSG( IsValid(n), NULL,
wxT("invalid index in wxListBox::GetClientData") );
return((void *)::WinSendMsg(GetHwnd(), LM_QUERYITEMHANDLE, MPFROMLONG(n), (MPARAM)0));
} // end of wxListBox::DoGetItemClientData
-void wxListBox::DoSetItemClientObject(
- int n
-, wxClientData* pClientData
-)
+void wxListBox::DoSetItemClientObject(int n, wxClientData* pClientData)
{
- DoSetItemClientData( n
- ,pClientData
- );
+ DoSetItemClientData(n, pClientData);
} // end of wxListBox::DoSetItemClientObject
-void wxListBox::DoSetItemClientData(
- int n
-, void* pClientData
-)
+void wxListBox::DoSetItemClientData(int n, void* pClientData)
{
- wxCHECK_RET( n >= 0 && n < m_nNumItems,
+ wxCHECK_RET( IsValid(n),
wxT("invalid index in wxListBox::SetClientData") );
#if wxUSE_OWNER_DRAWN
int wxListBox::GetSelections( wxArrayInt& raSelections ) const
{
- int nCount = 0;
- LONG lItem;
+ int nCount = 0;
+ LONG lItem;
raSelections.Empty();
));
} // end of wxListBox::GetSelection
-wxString wxListBox::GetString(
- int N
-) const
+wxString wxListBox::GetString( int N ) const
{
- LONG lLen = 0;
- wxChar* zBuf;
- wxString sResult;
+ LONG lLen = 0;
+ wxChar* zBuf;
+ wxString sResult;
- wxCHECK_MSG( N >= 0 && N < m_nNumItems, wxEmptyString,
+ wxCHECK_MSG( IsValid(N), wxEmptyString,
wxT("invalid index in wxListBox::GetClientData") );
lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0));
return sResult;
} // end of wxListBox::GetString
-void wxListBox::DoInsertItems(
- const wxArrayString& asItems
-, int nPos
-)
+void wxListBox::DoInsertItems( const wxArrayString& asItems,
+ int nPos )
{
- wxCHECK_RET( nPos >= 0 && nPos <= m_nNumItems,
+ wxCHECK_RET( IsValidInsert(nPos),
wxT("invalid index in wxListBox::InsertItems") );
- int nItems = asItems.GetCount();
+ size_t nItems = asItems.GetCount();
- for (int i = 0; i < nItems; i++)
+ for (size_t i = 0; i < nItems; i++)
{
- int nIndex = (int)::WinSendMsg( GetHwnd()
- ,LM_INSERTITEM
- ,MPFROMLONG((LONG)(i + nPos))
- ,(MPARAM)asItems[i].c_str()
- );
+ int nIndex = (int)::WinSendMsg( GetHwnd(),
+ LM_INSERTITEM,
+ MPFROMLONG((LONG)(i + nPos)),
+ (MPARAM)asItems[i].c_str() );
- wxOwnerDrawn* pNewItem = CreateItem(nIndex);
+ wxOwnerDrawn* pNewItem = CreateItem(nIndex);
pNewItem->SetName(asItems[i]);
pNewItem->SetFont(GetFont());
}
} // end of wxListBox::DoInsertItems
-void wxListBox::SetString(
- int N
-, const wxString& rsString
-)
+void wxListBox::SetString(int N, const wxString& rsString)
{
- wxCHECK_RET( N >= 0 && N < m_nNumItems,
+ wxCHECK_RET( IsValid(N),
wxT("invalid index in wxListBox::SetString") );
//
// Remember the state of the item
//
- bool bWasSelected = IsSelected(N);
- void* pOldData = NULL;
- wxClientData* pOldObjData = NULL;
+ bool bWasSelected = IsSelected(N);
+ void* pOldData = NULL;
+ wxClientData* pOldObjData = NULL;
if (m_clientDataItemsType == wxClientData_Void)
pOldData = GetClientData(N);
#endif //USE_OWNER_DRAWN
} // end of wxListBox::SetString
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
return m_nNumItems;
}
//
// Find the widest string
//
- int nLine;
- int nListbox = 0;
- int nCx;
- int nCy;
- wxFont vFont = (wxFont)GetFont();
+ int nLine;
+ int nListbox = 0;
+ int nCx;
+ int nCy;
+ wxFont vFont = (wxFont)GetFont();
- for (int i = 0; i < m_nNumItems; i++)
+ for (size_t i = 0; i < m_nNumItems; i++)
{
- wxString vStr(GetString(i));
+ wxString vStr(GetString(i));
- GetTextExtent( vStr
- ,&nLine
- ,NULL
- );
+ GetTextExtent( vStr, &nLine, NULL );
if (nLine > nListbox)
nListbox = nLine;
}
);
nListbox += 3 * nCx;
- int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
+ int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
return wxSize( nListbox
,hListbox
vEvent.SetEventObject(this);
- wxArrayInt aSelections;
- int n;
- int nCount = GetSelections(aSelections);
+ wxArrayInt aSelections;
+ int n;
+ int nCount = GetSelections(aSelections);
if (nCount > 0)
{
//
#define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1)
-long wxListBox::OS2OnMeasure(
- WXMEASUREITEMSTRUCT* pItem
-)
+long wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT* pItem)
{
if (!pItem)
pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;
#endif // ndef for wxUSE_OWNER_DRAWN
-#endif // ndef for wxUSE_LISTBOX
+#endif // wxUSE_LISTBOX
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
+#if wxUSE_RADIOBOX
+
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/wxchar.h"
wxRemoveHandleAssociation(this);
if (m_ahRadioButtons)
{
- for (int i = 0; i < m_nNoItems; i++)
+ for (size_t i = 0; i < m_nNoItems; i++)
{
wxWindow* pWin = wxFindWinFromHandle((WXHWND)m_ahRadioButtons[i]);
wxRemoveHandleAssociation(pWin);
delete[] m_pnRadioHeight;
} // end of wxRadioBox::~wxRadioBox
-void wxRadioBox::Command (
- wxCommandEvent& rEvent
-)
+void wxRadioBox::Command ( wxCommandEvent& rEvent )
{
SetSelection (rEvent.GetInt());
ProcessCommand(rEvent);
} // end of wxRadioBox::Command
-bool wxRadioBox::ContainsHWND(
- WXHWND hWnd
-) const
+bool wxRadioBox::ContainsHWND( WXHWND hWnd ) const
{
- size_t nCount = GetCount();
- size_t i;
+ size_t nCount = GetCount();
+ size_t i;
for (i = 0; i < nCount; i++)
{
return false;
} // end of wxRadioBox::ContainsHWND
-bool wxRadioBox::Create(
- wxWindow* pParent
-, wxWindowID vId
-, const wxString& rsTitle
-, const wxPoint& rPos
-, const wxSize& rSize
-, const wxArrayString& asChoices
-, int nMajorDim
-, long lStyle
-, const wxValidator& rVal
-, const wxString& rsName
-)
+bool wxRadioBox::Create( wxWindow* pParent,
+ wxWindowID vId,
+ const wxString& rsTitle,
+ const wxPoint& rPos,
+ const wxSize& rSize,
+ const wxArrayString& asChoices,
+ int nMajorDim,
+ long lStyle,
+ const wxValidator& rVal,
+ const wxString& rsName )
{
wxCArrayString chs(asChoices);
chs.GetStrings(), nMajorDim, lStyle, rVal, rsName);
}
-bool wxRadioBox::Create(
- wxWindow* pParent
-, wxWindowID vId
-, const wxString& rsTitle
-, const wxPoint& rPos
-, const wxSize& rSize
-, int nNum
-, const wxString asChoices[]
-, int nMajorDim
-, long lStyle
-, const wxValidator& rVal
-, const wxString& rsName
-)
-{
- wxColour vColour;
- LONG lColor;
- HWND hWndParent = GetHwndOf(pParent);
+bool wxRadioBox::Create( wxWindow* pParent,
+ wxWindowID vId,
+ const wxString& rsTitle,
+ const wxPoint& rPos,
+ const wxSize& rSize,
+ int nNum,
+ const wxString asChoices[],
+ int nMajorDim,
+ long lStyle,
+ const wxValidator& rVal,
+ const wxString& rsName )
+{
+ wxColour vColour;
+ LONG lColor;
+ HWND hWndParent = GetHwndOf(pParent);
vColour.Set(wxString(wxT("BLACK")));
m_backgroundColour = pParent->GetBackgroundColour();
//
// Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows
//
- m_nNoItems = nNum;
+ m_nNoItems = (size_t)nNum;
SetMajorDim(nMajorDim == 0 ? nNum : nMajorDim, lStyle);
m_ahRadioButtons = new WXHWND[nNum];
nStartX = nXOffset;
nStartY = nYOffset;
- for (int i = 0; i < m_nNoItems; i++)
+ for (size_t i = 0; i < m_nNoItems; i++)
{
//
// The last button in the row may be wider than the other ones as the
// radiobox may be wider than the sum of the button widths (as it
// happens, for example, when the radiobox label is very long)
//
- bool bIsLastInTheRow;
+ bool bIsLastInTheRow;
if (m_windowStyle & wxRA_SPECIFY_COLS)
{
return true;
} // end of wxRadioBox::Enable
-bool wxRadioBox::Enable(
- bool bEnable
-)
+bool wxRadioBox::Enable(bool bEnable)
{
if ( !wxControl::Enable(bEnable) )
return false;
- for (int i = 0; i < m_nNoItems; i++)
+ for (size_t i = 0; i < m_nNoItems; i++)
::WinEnableWindow((HWND)m_ahRadioButtons[i], bEnable);
return true;
} // end of wxRadioBox::Enable
-int wxRadioBox::GetCount() const
+size_t wxRadioBox::GetCount() const
{
return m_nNoItems;
} // end of wxRadioBox::GetCount
wxSize wxRadioBox::GetMaxButtonSize() const
{
- int nWidthMax = 0;
- int nHeightMax = 0;
+ int nWidthMax = 0;
+ int nHeightMax = 0;
- for (int i = 0 ; i < m_nNoItems; i++)
+ for (size_t i = 0 ; i < m_nNoItems; i++)
{
- int nWidth;
- int nHeight;
+ int nWidth;
+ int nHeight;
if (m_pnRadioWidth[i] < 0L)
{
void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const
{
- RECT vRect;
+ RECT vRect;
vRect.xLeft = -1;
vRect.xRight = -1;
vRect.yBottom = -1;
if (m_hWnd)
- wxFindMaxSize( m_hWnd
- ,&vRect
- );
+ wxFindMaxSize( m_hWnd, &vRect );
- for (int i = 0; i < m_nNoItems; i++)
- wxFindMaxSize( m_ahRadioButtons[i]
- ,&vRect
- );
+ for (size_t i = 0; i < m_nNoItems; i++)
+ wxFindMaxSize( m_ahRadioButtons[i], &vRect );
if (pnWidth)
*pnWidth = vRect.xRight - vRect.xLeft;
if (wId == GetId())
return true;
- for (int i = 0; i < m_nNoItems; i++)
+ for (size_t i = 0; i < m_nNoItems; i++)
{
if (wId == wxGetWindowId(m_ahRadioButtons[i]))
{
}
} // end of wxRadioBox::SetFocus
-bool wxRadioBox::SetFont(
- const wxFont& rFont
-)
+bool wxRadioBox::SetFont(const wxFont& rFont)
{
if (!wxControl::SetFont(rFont))
{
//
// Also set the font of our radio buttons
//
- for (int n = 0; n < (int)m_nNoItems; n++)
+ for (size_t n = 0; n < m_nNoItems; n++)
{
- HWND hWndBtn = (HWND)m_ahRadioButtons[n];
+ HWND hWndBtn = (HWND)m_ahRadioButtons[n];
- wxOS2SetFont( hWndBtn
- ,rFont
- );
+ wxOS2SetFont( hWndBtn, rFont );
::WinInvalidateRect(hWndBtn, NULL, FALSE);
}
return true;
return false;
} // end of wxRadioBox::SetStringSelection
-bool wxRadioBox::Show(
- bool bShow
-)
+bool wxRadioBox::Show(bool bShow)
{
if (!wxControl::Show(bShow))
return false;
- for (int i = 0; i < m_nNoItems; i++)
+ for (size_t i = 0; i < m_nNoItems; i++)
{
::WinShowWindow((HWND)m_ahRadioButtons[i], (BOOL)bShow);
}
(MPARAM)lParam )
);
} // end of wxRadioBoxWndProc
+
+#endif // wxUSE_RADIOBOX
// string list functions
// ----------------------------------------------------------------------------
-int wxChoice::GetCount() const
+size_t wxChoice::GetCount() const
{
return 0;
}
wxListBoxItem(const wxString& str = wxEmptyString);
};
-wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
+wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, false)
{
// no bitmaps/checkmarks
SetMarginWidth(0);
{
}
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
{
- return m_noItems;
+ return 0;
}
// ----------------------------------------------------------------------------
m_size = wxSize(0,0);
}
-int wxRadioBox::GetCount() const
+size_t wxRadioBox::GetCount() const
{
return m_radios.GetCount();
}
const bool use_cols = HasFlag(wxRA_SPECIFY_COLS);
- const int n = GetCount();
- int minor = n / GetMajorDim();
+ const size_t n = GetCount();
+ size_t minor = n / GetMajorDim();
if(n % GetMajorDim() > 0)
minor++;
- int i = 0;
+ size_t i = 0;
for ( int j = 0; j < minor; j++ )
{
for ( int k = 0; k < GetMajorDim(); k++ )
// Enable all subcontrols
bool wxRadioBox::Enable(bool enable)
{
- for(int i=0; i<GetCount(); i++)
- Enable(i, enable);
+ for(size_t i=0; i<GetCount(); i++)
+ Enable((int)i, enable);
return true;
}
bool wxRadioBox::Show(bool show)
{
- for(int i=0; i<GetCount(); i++)
- Show(i, show);
+ for(size_t i=0; i<GetCount(); i++)
+ Show((int)i, show);
return true;
}
// always matches), but we want to show the first one in such case
if ( value.empty() )
{
- if ( GetCount() )
+ if ( GetCount() > 0 )
{
wxListBox::SetSelection(0);
}
void wxComboBox::Delete(int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Delete") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::Delete") );
if (GetSelection() == n)
GetText()->SetValue(wxEmptyString);
GetLBox()->Delete(n);
}
-int wxComboBox::GetCount() const
+size_t wxComboBox::GetCount() const
{
return GetLBox()->GetCount();
}
wxString wxComboBox::GetString(int n) const
{
- wxCHECK_MSG( (n >= 0) && (n < GetCount()), wxEmptyString, _T("invalid index in wxComboBox::GetString") );
+ wxCHECK_MSG( IsValid(n), wxEmptyString, _T("invalid index in wxComboBox::GetString") );
return GetLBox()->GetString(n);
}
void wxComboBox::SetString(int n, const wxString& s)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::SetString") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::SetString") );
GetLBox()->SetString(n, s);
}
void wxComboBox::SetSelection(int n)
{
- wxCHECK_RET( (n >= 0) && (n < GetCount()), _T("invalid index in wxComboBox::Select") );
+ wxCHECK_RET( IsValid(n), _T("invalid index in wxComboBox::Select") );
GetLBox()->SetSelection(n);
GetText()->SetValue(GetLBox()->GetString(n));
int wxComboBox::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
- 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);
GetLBox()->Insert(item, pos);
/////////////////////////////////////////////////////////////////////////////
-// Name: univ/listbox.cpp
+// Name: src/univ/listbox.cpp
// Purpose: wxListBox implementation
// Author: Vadim Zeitlin
// Modified by:
void wxListBox::Delete(int n)
{
- wxCHECK_RET( n >= 0 && n < GetCount(),
+ wxCHECK_RET( IsValid(n),
_T("invalid index in wxListBox::Delete") );
// do it before removing the index as otherwise the last item will not be
wxSize size = GetClientSize();
// is our height enough to show all items?
- int nLines = GetCount();
+ size_t nLines = GetCount();
wxCoord lineHeight = GetLineHeight();
bool showScrollbarY = nLines*lineHeight > size.y;
bool wxListBox::FindItem(const wxString& prefix, bool strictlyAfter)
{
- int count = GetCount();
- if ( !count )
+ size_t count = GetCount();
+ if ( count==0 )
{
// empty listbox, we can't find anything in it
return false;
int last = first == 0 ? count - 1 : first - 1;
// if this is not true we'd never exit from the loop below!
- wxASSERT_MSG( first < count && last < count, _T("logic error") );
+ wxASSERT_MSG( first < (int)count && last < (int)count, _T("logic error") );
// precompute it outside the loop
size_t len = prefix.length();
// loop over all items in the listbox
- for ( int item = first; item != last; item < count - 1 ? item++ : item = 0 )
+ for ( int item = first; item != (int)last; item < count - 1 ? item++ : item = 0 )
{
if ( wxStrnicmp(this->GetString(item).c_str(), prefix, len) == 0 )
{
SetSelection(n);
}
- int count = GetCount();
- for ( ; n < count; n++ )
+ size_t count = GetCount();
+ for ( ; n < (int)count; n++ )
{
Deselect(n);
}
// mouse is above the first item
item = 0;
}
- else if ( item >= lbox->GetCount() )
+ else if ( (size_t)item >= lbox->GetCount() )
{
// mouse is below the last item
item = lbox->GetCount() - 1;
bool wxStdListboxInputHandler::IsValidIndex(const wxListBox *lbox, int item)
{
- return item >= 0 && item < lbox->GetCount();
+ return item >= 0 && (size_t)item < lbox->GetCount();
}
wxControlAction
/////////////////////////////////////////////////////////////////////////////
-// Name: univ/radiobox.cpp
+// Name: src/univ/radiobox.cpp
// Purpose: wxRadioBox implementation
// Author: Vadim Zeitlin
// Modified by:
return false;
// also enable/disable the buttons
- size_t count = m_buttons.GetCount();
+ const size_t count = m_buttons.GetCount();
for ( size_t n = 0; n < count; n++ )
{
Enable(n, enable);
return false;
// also show/hide the buttons
- size_t count = m_buttons.GetCount();
+ const size_t count = m_buttons.GetCount();
for ( size_t n = 0; n < count; n++ )
{
Show(n, show);
wxControl::DoSetToolTip(tooltip);
// Also set them for all Radio Buttons
- size_t count = m_buttons.GetCount();
+ const size_t count = m_buttons.GetCount();
for ( size_t n = 0; n < count; n++ )
{
if (tooltip)
int widthMax, heightMax, width = 0, height = 0;
widthMax = heightMax = 0;
- int count = GetCount();
+ const int count = GetCount();
for ( int n = 0; n < count; n++ )
{
m_buttons[n]->GetBestSize(&width, &height);
int x = x0,
y = y0;
- int count = GetCount();
- for ( int n = 0; n < count; n++ )
+ const size_t count = GetCount();
+ for ( size_t n = 0; n < count; n++ )
{
m_buttons[n]->SetSize(x, y, sizeBtn.x, sizeBtn.y);
}
#endif // wxUSE_RADIOBOX
-