From 8228b8932abaedadbf9568bb3a1eef3ae25fb2a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?W=C5=82odzimierz=20Skiba?= Date: Tue, 14 Mar 2006 19:44:45 +0000 Subject: [PATCH] Line-up interfaces to use size_t for GetCount()s (and count related api). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38076 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/choice.h | 2 +- include/wx/cocoa/combobox.h | 2 +- include/wx/cocoa/listbox.h | 2 +- include/wx/cocoa/radiobox.h | 4 +- include/wx/ctrlsub.h | 10 +- include/wx/gtk/choice.h | 4 +- include/wx/gtk/combobox.h | 3 +- include/wx/gtk/listbox.h | 6 +- include/wx/gtk/radiobox.h | 2 +- include/wx/gtk1/choice.h | 4 +- include/wx/gtk1/combobox.h | 3 +- include/wx/gtk1/listbox.h | 2 +- include/wx/gtk1/radiobox.h | 2 +- include/wx/mac/carbon/choice.h | 2 +- include/wx/mac/carbon/combobox.h | 2 +- include/wx/mac/carbon/listbox.h | 6 +- include/wx/mac/carbon/radiobox.h | 9 +- include/wx/mac/classic/choice.h | 2 +- include/wx/mac/classic/combobox.h | 2 +- include/wx/mac/classic/listbox.h | 6 +- include/wx/mac/classic/radiobox.h | 9 +- include/wx/motif/choice.h | 2 +- include/wx/motif/listbox.h | 4 +- include/wx/motif/radiobox.h | 4 +- include/wx/msw/choice.h | 2 +- include/wx/msw/listbox.h | 4 +- include/wx/msw/radiobox.h | 2 +- include/wx/msw/wince/checklst.h | 2 +- include/wx/msw/wince/choicece.h | 2 +- include/wx/os2/choice.h | 2 +- include/wx/os2/listbox.h | 15 +-- include/wx/os2/radiobox.h | 5 +- include/wx/palmos/choice.h | 2 +- include/wx/palmos/listbox.h | 3 +- include/wx/palmos/radiobox.h | 11 +- include/wx/univ/combobox.h | 2 +- include/wx/univ/listbox.h | 4 +- include/wx/univ/radiobox.h | 2 +- samples/checklst/checklst.cpp | 2 +- src/cocoa/choice.mm | 4 +- src/cocoa/combobox.mm | 5 +- src/cocoa/listbox.mm | 6 +- src/cocoa/radiobox.mm | 7 +- src/gtk/choice.cpp | 31 +++-- src/gtk/combobox.cpp | 154 ++++++++++++------------ src/gtk/listbox.cpp | 51 ++++---- src/gtk/radiobox.cpp | 4 +- src/gtk1/choice.cpp | 28 ++--- src/gtk1/combobox.cpp | 31 +++-- src/gtk1/listbox.cpp | 18 +-- src/gtk1/radiobox.cpp | 2 +- src/mac/carbon/choice.cpp | 28 ++--- src/mac/carbon/combobox.cpp | 2 +- src/mac/carbon/listbox.cpp | 60 +++++----- src/mac/carbon/radiobox.cpp | 16 ++- src/mac/classic/checklst.cpp | 86 +++++++------- src/mac/classic/choice.cpp | 14 +-- src/mac/classic/listbox.cpp | 56 +++++---- src/mac/classic/radiobox.cpp | 24 ++-- src/motif/choice.cpp | 12 +- src/motif/combobox.cpp | 4 +- src/motif/listbox.cpp | 11 +- src/motif/radiobox.cpp | 23 ++-- src/msw/checklst.cpp | 7 +- src/msw/choice.cpp | 19 ++- src/msw/listbox.cpp | 37 +++--- src/msw/radiobox.cpp | 16 +-- src/msw/wince/checklst.cpp | 23 ++-- src/msw/wince/choicece.cpp | 21 ++-- src/os2/checklst.cpp | 4 +- src/os2/choice.cpp | 58 ++++----- src/os2/listbox.cpp | 191 ++++++++++++------------------ src/os2/radiobox.cpp | 128 +++++++++----------- src/palmos/choice.cpp | 2 +- src/palmos/listbox.cpp | 6 +- src/palmos/radiobox.cpp | 16 +-- src/univ/combobox.cpp | 16 +-- src/univ/listbox.cpp | 22 ++-- src/univ/radiobox.cpp | 15 ++- 79 files changed, 667 insertions(+), 745 deletions(-) diff --git a/include/wx/cocoa/choice.h b/include/wx/cocoa/choice.h index c4f8a5dcb7..a6c53ef892 100644 --- a/include/wx/cocoa/choice.h +++ b/include/wx/cocoa/choice.h @@ -82,7 +82,7 @@ protected: 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; diff --git a/include/wx/cocoa/combobox.h b/include/wx/cocoa/combobox.h index 45225f9bc5..cc1dc9ab6f 100644 --- a/include/wx/cocoa/combobox.h +++ b/include/wx/cocoa/combobox.h @@ -108,7 +108,7 @@ public: // 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; diff --git a/include/wx/cocoa/listbox.h b/include/wx/cocoa/listbox.h index 9d5f21d6f3..d5cf9502f4 100644 --- a/include/wx/cocoa/listbox.h +++ b/include/wx/cocoa/listbox.h @@ -95,7 +95,7 @@ public: 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; diff --git a/include/wx/cocoa/radiobox.h b/include/wx/cocoa/radiobox.h index d8d0aafa6b..0faacf6ccd 100644 --- a/include/wx/cocoa/radiobox.h +++ b/include/wx/cocoa/radiobox.h @@ -4,7 +4,7 @@ // Author: David Elliott // Modified by: // Created: 2003/03/18 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) 2003 David Elliott // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -85,7 +85,7 @@ public: 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 diff --git a/include/wx/ctrlsub.h b/include/wx/ctrlsub.h index cf5c943c07..216ab3ab4a 100644 --- a/include/wx/ctrlsub.h +++ b/include/wx/ctrlsub.h @@ -38,7 +38,7 @@ public: // 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; @@ -50,9 +50,9 @@ public: // 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; @@ -82,7 +82,9 @@ public: 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 diff --git a/include/wx/gtk/choice.h b/include/wx/gtk/choice.h index 28a5efdcc0..1ae716df6f 100644 --- a/include/wx/gtk/choice.h +++ b/include/wx/gtk/choice.h @@ -69,7 +69,7 @@ public: 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 ); @@ -95,7 +95,7 @@ protected: 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) diff --git a/include/wx/gtk/combobox.h b/include/wx/gtk/combobox.h index 357a476a39..5852b7403c 100644 --- a/include/wx/gtk/combobox.h +++ b/include/wx/gtk/combobox.h @@ -88,8 +88,7 @@ public: 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); diff --git a/include/wx/gtk/listbox.h b/include/wx/gtk/listbox.h index bda269fb16..92df4f2497 100644 --- a/include/wx/gtk/listbox.h +++ b/include/wx/gtk/listbox.h @@ -65,7 +65,7 @@ public: 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; @@ -98,8 +98,8 @@ public: 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: diff --git a/include/wx/gtk/radiobox.h b/include/wx/gtk/radiobox.h index 08dc999f55..d2d9104b74 100644 --- a/include/wx/gtk/radiobox.h +++ b/include/wx/gtk/radiobox.h @@ -81,7 +81,7 @@ public: // 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); diff --git a/include/wx/gtk1/choice.h b/include/wx/gtk1/choice.h index e8fc3a7f16..55acb8d49a 100644 --- a/include/wx/gtk1/choice.h +++ b/include/wx/gtk1/choice.h @@ -69,7 +69,7 @@ public: 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 ); @@ -95,7 +95,7 @@ protected: 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) diff --git a/include/wx/gtk1/combobox.h b/include/wx/gtk1/combobox.h index d4e6df33cd..a3a3d2a178 100644 --- a/include/wx/gtk1/combobox.h +++ b/include/wx/gtk1/combobox.h @@ -88,8 +88,7 @@ public: 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); diff --git a/include/wx/gtk1/listbox.h b/include/wx/gtk1/listbox.h index 4902dd166c..92b6e8203e 100644 --- a/include/wx/gtk1/listbox.h +++ b/include/wx/gtk1/listbox.h @@ -70,7 +70,7 @@ public: 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; diff --git a/include/wx/gtk1/radiobox.h b/include/wx/gtk1/radiobox.h index 3327b78cdb..a2fc5ece73 100644 --- a/include/wx/gtk1/radiobox.h +++ b/include/wx/gtk1/radiobox.h @@ -81,7 +81,7 @@ public: // 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); diff --git a/include/wx/mac/carbon/choice.h b/include/wx/mac/carbon/choice.h index 2b0ac93311..3dbe9c23af 100644 --- a/include/wx/mac/carbon/choice.h +++ b/include/wx/mac/carbon/choice.h @@ -72,7 +72,7 @@ public: 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(); } diff --git a/include/wx/mac/carbon/combobox.h b/include/wx/mac/carbon/combobox.h index 7c574d008f..f9007107bb 100644 --- a/include/wx/mac/carbon/combobox.h +++ b/include/wx/mac/carbon/combobox.h @@ -114,7 +114,7 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase virtual void SetEditable(bool editable); virtual bool IsEditable() const; - virtual int GetCount() const; + virtual size_t GetCount() const; virtual void Undo(); virtual void Redo(); diff --git a/include/wx/mac/carbon/listbox.h b/include/wx/mac/carbon/listbox.h index 7aa58cc559..090fc5b728 100644 --- a/include/wx/mac/carbon/listbox.h +++ b/include/wx/mac/carbon/listbox.h @@ -71,13 +71,13 @@ public: 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; @@ -132,7 +132,7 @@ protected: // 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 ; diff --git a/include/wx/mac/carbon/radiobox.h b/include/wx/mac/carbon/radiobox.h index 6a895305fe..0f5d7d53ac 100644 --- a/include/wx/mac/carbon/radiobox.h +++ b/include/wx/mac/carbon/radiobox.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: radiobox.h +// Name: wx/mac/carbon/radiobox.h // Purpose: wxRadioBox class // Author: Stefan Csomor // Modified by: @@ -58,7 +58,7 @@ public: 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) ; @@ -80,10 +80,11 @@ public: 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 diff --git a/include/wx/mac/classic/choice.h b/include/wx/mac/classic/choice.h index d3af0db711..8a2fa8ae0c 100644 --- a/include/wx/mac/classic/choice.h +++ b/include/wx/mac/classic/choice.h @@ -75,7 +75,7 @@ public: 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); diff --git a/include/wx/mac/classic/combobox.h b/include/wx/mac/classic/combobox.h index 6fc7a51efb..278606b73a 100644 --- a/include/wx/mac/classic/combobox.h +++ b/include/wx/mac/classic/combobox.h @@ -104,7 +104,7 @@ class WXDLLEXPORT wxComboBox : public wxControl, public wxComboBoxBase 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 ; diff --git a/include/wx/mac/classic/listbox.h b/include/wx/mac/classic/listbox.h index 67a7e895eb..3e77885df7 100644 --- a/include/wx/mac/classic/listbox.h +++ b/include/wx/mac/classic/listbox.h @@ -81,13 +81,13 @@ public: 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; @@ -156,7 +156,7 @@ protected: // 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 ; diff --git a/include/wx/mac/classic/radiobox.h b/include/wx/mac/classic/radiobox.h index 6a895305fe..4f184209ce 100644 --- a/include/wx/mac/classic/radiobox.h +++ b/include/wx/mac/classic/radiobox.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: radiobox.h +// Name: wx/mac/classic/radiobox.h // Purpose: wxRadioBox class // Author: Stefan Csomor // Modified by: @@ -58,7 +58,7 @@ public: 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) ; @@ -80,10 +80,11 @@ public: 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 diff --git a/include/wx/motif/choice.h b/include/wx/motif/choice.h index a89d1da9f6..731a3b8f94 100644 --- a/include/wx/motif/choice.h +++ b/include/wx/motif/choice.h @@ -71,7 +71,7 @@ public: 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); diff --git a/include/wx/motif/listbox.h b/include/wx/motif/listbox.h index 8f4b5b04df..002c80de52 100644 --- a/include/wx/motif/listbox.h +++ b/include/wx/motif/listbox.h @@ -66,7 +66,7 @@ public: ~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; @@ -101,7 +101,7 @@ public: protected: virtual wxSize DoGetBestSize() const; - int m_noItems; + size_t m_noItems; // List mapping positions->client data wxClientDataDictionary m_clientDataDict; diff --git a/include/wx/motif/radiobox.h b/include/wx/motif/radiobox.h index 7b1ad3d78b..6284a8033c 100644 --- a/include/wx/motif/radiobox.h +++ b/include/wx/motif/radiobox.h @@ -84,7 +84,7 @@ public: 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; } @@ -103,7 +103,7 @@ protected: int width, int height, int sizeFlags = wxSIZE_AUTO); - int m_noItems; + size_t m_noItems; int m_noRowsOrCols; int m_selectedButton; diff --git a/include/wx/msw/choice.h b/include/wx/msw/choice.h index e6207d187d..f5f10b665e 100644 --- a/include/wx/msw/choice.h +++ b/include/wx/msw/choice.h @@ -69,7 +69,7 @@ public: 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); diff --git a/include/wx/msw/listbox.h b/include/wx/msw/listbox.h index 1ed147948b..0e9cf02d40 100644 --- a/include/wx/msw/listbox.h +++ b/include/wx/msw/listbox.h @@ -81,7 +81,7 @@ public: 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; @@ -147,7 +147,7 @@ protected: // free memory (common part of Clear() and dtor) void Free(); - int m_noItems; + size_t m_noItems; int m_selected; virtual wxSize DoGetBestSize() const; diff --git a/include/wx/msw/radiobox.h b/include/wx/msw/radiobox.h index 9470e308cb..d800706141 100644 --- a/include/wx/msw/radiobox.h +++ b/include/wx/msw/radiobox.h @@ -85,7 +85,7 @@ public: // 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); diff --git a/include/wx/msw/wince/checklst.h b/include/wx/msw/wince/checklst.h index 75ad7a92ed..5cc5ff0fbe 100644 --- a/include/wx/msw/wince/checklst.h +++ b/include/wx/msw/wince/checklst.h @@ -58,7 +58,7 @@ public: // 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; diff --git a/include/wx/msw/wince/choicece.h b/include/wx/msw/wince/choicece.h index e7f6781e60..027837225a 100644 --- a/include/wx/msw/wince/choicece.h +++ b/include/wx/msw/wince/choicece.h @@ -83,7 +83,7 @@ public: 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); diff --git a/include/wx/os2/choice.h b/include/wx/os2/choice.h index 5700c35de4..4040e66663 100644 --- a/include/wx/os2/choice.h +++ b/include/wx/os2/choice.h @@ -94,7 +94,7 @@ public: 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); diff --git a/include/wx/os2/listbox.h b/include/wx/os2/listbox.h index 4c67ca7fcd..01070daa9e 100644 --- a/include/wx/os2/listbox.h +++ b/include/wx/os2/listbox.h @@ -106,21 +106,17 @@ public: 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 ); @@ -158,9 +154,8 @@ protected: 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 // diff --git a/include/wx/os2/radiobox.h b/include/wx/os2/radiobox.h index 5255f389c3..24419a2803 100644 --- a/include/wx/os2/radiobox.h +++ b/include/wx/os2/radiobox.h @@ -125,7 +125,7 @@ public: - 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 @@ -170,12 +170,13 @@ protected: 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 diff --git a/include/wx/palmos/choice.h b/include/wx/palmos/choice.h index ed1a42aca1..d4054dada7 100644 --- a/include/wx/palmos/choice.h +++ b/include/wx/palmos/choice.h @@ -69,7 +69,7 @@ public: 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); diff --git a/include/wx/palmos/listbox.h b/include/wx/palmos/listbox.h index fcf443706d..ec32855dc6 100644 --- a/include/wx/palmos/listbox.h +++ b/include/wx/palmos/listbox.h @@ -81,7 +81,7 @@ public: 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); @@ -141,7 +141,6 @@ protected: // free memory (common part of Clear() and dtor) void Free(); - int m_noItems; int m_selected; virtual wxSize DoGetBestSize() const; diff --git a/include/wx/palmos/radiobox.h b/include/wx/palmos/radiobox.h index 03b0941b78..c36c989317 100644 --- a/include/wx/palmos/radiobox.h +++ b/include/wx/palmos/radiobox.h @@ -88,7 +88,7 @@ public: // 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); @@ -136,12 +136,11 @@ protected: // 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; diff --git a/include/wx/univ/combobox.h b/include/wx/univ/combobox.h index 3d58e1fd6d..9230e4dbe0 100644 --- a/include/wx/univ/combobox.h +++ b/include/wx/univ/combobox.h @@ -294,7 +294,7 @@ public: // 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; diff --git a/include/wx/univ/listbox.h b/include/wx/univ/listbox.h index 163b9b4f22..a82785f5ba 100644 --- a/include/wx/univ/listbox.h +++ b/include/wx/univ/listbox.h @@ -99,8 +99,8 @@ public: 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); diff --git a/include/wx/univ/radiobox.h b/include/wx/univ/radiobox.h index 784b14da87..23d05281d6 100644 --- a/include/wx/univ/radiobox.h +++ b/include/wx/univ/radiobox.h @@ -84,7 +84,7 @@ public: 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); diff --git a/samples/checklst/checklst.cpp b/samples/checklst/checklst.cpp index 9ae58191f4..bbf3d8b96e 100644 --- a/samples/checklst/checklst.cpp +++ b/samples/checklst/checklst.cpp @@ -499,7 +499,7 @@ void CheckListBoxFrame::OnButtonMove(bool up) 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")); } diff --git a/src/cocoa/choice.mm b/src/cocoa/choice.mm index 3c5d479162..8f15536bd5 100644 --- a/src/cocoa/choice.mm +++ b/src/cocoa/choice.mm @@ -156,9 +156,9 @@ void wxChoice::Delete(int n) [(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 diff --git a/src/cocoa/combobox.mm b/src/cocoa/combobox.mm index 0e19e3d340..9be77501ac 100644 --- a/src/cocoa/combobox.mm +++ b/src/cocoa/combobox.mm @@ -75,6 +75,7 @@ // ---------------------------------------------------------------------------- #include "wx/wxprec.h" + #if wxUSE_COMBOBOX #ifndef WX_PRECOMP @@ -260,9 +261,9 @@ void wxComboBox::Delete(int nIndex) 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 diff --git a/src/cocoa/listbox.mm b/src/cocoa/listbox.mm index 01cba46d60..78ac457181 100644 --- a/src/cocoa/listbox.mm +++ b/src/cocoa/listbox.mm @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: cocoa/listbox.mm +// Name: src/cocoa/listbox.mm // Purpose: wxListBox // Author: David Elliott // Modified by: @@ -224,9 +224,9 @@ void wxListBox::Delete(int n) } // 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 diff --git a/src/cocoa/radiobox.mm b/src/cocoa/radiobox.mm index 4dc469c0dd..aa699a7e2d 100644 --- a/src/cocoa/radiobox.mm +++ b/src/cocoa/radiobox.mm @@ -1,10 +1,10 @@ ///////////////////////////////////////////////////////////////////////////// -// 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 ///////////////////////////////////////////////////////////////////////////// @@ -76,7 +76,7 @@ int wxRadioBox::GetSelection() const } // string access -int wxRadioBox::GetCount() const +size_t wxRadioBox::GetCount() const { return 0; } @@ -109,4 +109,3 @@ wxSize wxRadioBox::DoGetBestSize() const } #endif - diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 78ea983c3c..80343f91c1 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -7,7 +7,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/defs.h" +#include "wx/wxprec.h" #if wxUSE_CHOICE @@ -120,7 +120,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, GtkWidget *menu = gtk_menu_new(); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < (size_t)n; i++) { GtkAddHelper(menu, i, choices[i]); } @@ -154,9 +154,9 @@ int wxChoice::DoAppend( const wxString &item ) int wxChoice::DoInsert( const wxString &item, int pos ) { wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") ); - wxCHECK_MSG( (pos>=0) && (pos<=GetCount()), -1, wxT("invalid index")); + wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index")); - if (pos == GetCount()) + if ((size_t)pos == GetCount()) return DoAppend(item); GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ); @@ -168,7 +168,7 @@ int wxChoice::DoInsert( const wxString &item, int pos ) m_selection_hack++; } - return GtkAddHelper(menu, pos, item); + return GtkAddHelper(menu, (size_t)pos, item); } void wxChoice::DoSetItemClientData( int n, void* clientData ) @@ -246,13 +246,12 @@ void wxChoice::Clear() 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)) @@ -276,7 +275,7 @@ void wxChoice::Delete( int n ) items.Alloc(count); for ( i = 0; i < count; i++ ) { - if ( i != n ) + if ( i != (size_t)n ) { items.Add(GetString(i)); if ( hasClientData ) @@ -418,12 +417,12 @@ wxString wxChoice::GetString( int n ) const return wxEmptyString; } -int wxChoice::GetCount() const +size_t wxChoice::GetCount() const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid choice") ); GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; + size_t count = 0; GList *child = menu_shell->children; while (child) { @@ -441,7 +440,7 @@ void wxChoice::SetSelection( int n ) gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); // set the local selection variable manually - if ((n >= 0) && (n < GetCount())) + if ((n >= 0) && (n < (int)GetCount())) { // a valid selection has been made m_selection_hack = n; @@ -484,9 +483,9 @@ void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style) } } -int wxChoice::GtkAddHelper(GtkWidget *menu, int pos, const wxString& item) +int wxChoice::GtkAddHelper(GtkWidget *menu, size_t pos, const wxString& item) { - wxCHECK_MSG((pos>=0) && (pos<=(int)m_clientList.GetCount()), -1, wxT("invalid index")); + wxCHECK_MSG(IsValidInsert(pos), -1, wxT("invalid index")); GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) ); @@ -514,7 +513,7 @@ int wxChoice::GtkAddHelper(GtkWidget *menu, int pos, const wxString& 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 ); diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 467a6ce586..f1bf7b63f5 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -10,10 +10,10 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/combobox.h" - #if wxUSE_COMBOBOX +#include "wx/combobox.h" + #include "wx/settings.h" #include "wx/arrstr.h" #include "wx/intl.h" @@ -261,9 +261,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, { 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] ) ); @@ -277,7 +277,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, { 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. @@ -293,7 +293,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, 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++) @@ -317,9 +317,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, 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); @@ -335,13 +335,13 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, 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); } @@ -367,7 +367,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value, 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(); @@ -446,12 +446,12 @@ int wxComboBox::DoAppend( const wxString &item ) 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(); @@ -465,11 +465,11 @@ int wxComboBox::DoInsert( const wxString &item, int pos ) 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__ @@ -502,12 +502,12 @@ int wxComboBox::DoInsert( const wxString &item, int pos ) 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(); @@ -565,7 +565,7 @@ void wxComboBox::Clear() 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 ); } @@ -575,7 +575,7 @@ void wxComboBox::Clear() 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) { @@ -599,8 +599,8 @@ void wxComboBox::Delete( int n ) #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 ); } @@ -625,7 +625,7 @@ void wxComboBox::Delete( int n ) EnableEvents(); } - + wxList::compatibility_iterator node = m_clientObjectList.Item( n ); if (node) { @@ -649,8 +649,8 @@ void wxComboBox::SetString(int n, const wxString &text) 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)) @@ -679,7 +679,7 @@ void wxComboBox::SetString(int n, const wxString &text) wxFAIL_MSG( wxT("wxComboBox: wrong index") ); } } - + InvalidateBestSize(); } @@ -697,18 +697,18 @@ int wxComboBox::FindString( const wxString &item, bool bCase ) const 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 @@ -788,7 +788,7 @@ wxString wxComboBox::GetString( int n ) const wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid combobox") ); wxString str; - + #ifdef __WXGTK24__ if (!gtk_check_version(2,4,0)) { @@ -806,7 +806,7 @@ wxString wxComboBox::GetString( int n ) const } else #endif - { + { GtkWidget *list = GTK_COMBO(m_widget)->list; GList *child = g_list_nth( GTK_LIST(list)->children, n ); @@ -840,7 +840,7 @@ wxString wxComboBox::GetStringSelection() const } else #endif - { + { GtkWidget *list = GTK_COMBO(m_widget)->list; GList *selection = GTK_LIST(list)->selection; @@ -858,7 +858,7 @@ wxString wxComboBox::GetStringSelection() const return wxEmptyString; } -int wxComboBox::GetCount() const +size_t wxComboBox::GetCount() const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") ); @@ -871,22 +871,22 @@ int wxComboBox::GetCount() const 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; } @@ -910,7 +910,7 @@ void wxComboBox::SetSelection( int n ) gtk_list_select_item( GTK_LIST(list), n ); m_prevSelection = n; } - + EnableEvents(); } @@ -921,9 +921,9 @@ wxString wxComboBox::GetValue() const 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 @@ -947,9 +947,9 @@ void wxComboBox::SetValue( const wxString& value ) 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 ) ); @@ -966,9 +966,9 @@ void wxComboBox::Copy() 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)); } @@ -981,9 +981,9 @@ void wxComboBox::Cut() 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)); } @@ -996,9 +996,9 @@ void wxComboBox::Paste() 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)); } @@ -1071,9 +1071,9 @@ void wxComboBox::SetInsertionPoint( long 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 ); - + gtk_entry_set_position( entry, (int)pos ); } @@ -1084,9 +1084,9 @@ long wxComboBox::GetInsertionPoint() const 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)); } @@ -1097,9 +1097,9 @@ wxTextPos wxComboBox::GetLastPosition() const 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; } @@ -1113,9 +1113,9 @@ void wxComboBox::Replace( long from, long to, const wxString& value ) 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; @@ -1124,7 +1124,7 @@ void wxComboBox::Replace( long from, long to, const wxString& value ) wxCharBuffer buffer = wxConvUTF8.cWX2MB( value ); gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos ); #else - gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.Length(), &pos ); + gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos ); #endif } @@ -1135,9 +1135,9 @@ void wxComboBox::SetSelection( long from, long 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 ); - + gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to ); } @@ -1148,9 +1148,9 @@ void wxComboBox::GetSelection( long* from, long* to ) const 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); @@ -1168,9 +1168,9 @@ void wxComboBox::SetEditable( bool editable ) 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 ); } @@ -1215,18 +1215,18 @@ void wxComboBox::DisableEvents() #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); } @@ -1239,12 +1239,12 @@ void wxComboBox::EnableEvents() { 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), @@ -1314,9 +1314,9 @@ GtkWidget* wxComboBox::GetConnectWidget() 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 ); } @@ -1330,7 +1330,7 @@ bool wxComboBox::IsOwnGtkWindow( GdkWindow *window ) return (window == entry->text_area); } else -#endif +#endif { entry = GTK_ENTRY( GTK_COMBO(m_widget)->entry ); return ( (window == entry->text_area) || diff --git a/src/gtk/listbox.cpp b/src/gtk/listbox.cpp index 5712ee3955..cd8381475d 100644 --- a/src/gtk/listbox.cpp +++ b/src/gtk/listbox.cpp @@ -591,7 +591,7 @@ wxListBox::~wxListBox() // ---------------------------------------------------------------------------- void wxListBox::GtkInsertItems(const wxArrayString& items, - void** clientData, int pos) + void** clientData, size_t pos) { wxCHECK_RET( m_treeview != NULL, wxT("invalid listbox") ); @@ -600,7 +600,7 @@ void wxListBox::GtkInsertItems(const wxArrayString& items, // 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 @@ -610,7 +610,7 @@ void wxListBox::GtkInsertItems(const wxArrayString& items, 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")); @@ -625,10 +625,10 @@ void wxListBox::GtkInsertItems(const wxArrayString& items, 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 @@ -662,13 +662,15 @@ void wxListBox::GtkInsertItems(const wxArrayString& items, 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); @@ -730,7 +732,7 @@ struct _GtkTreeEntry* wxListBox::GtkGetEntry(int n) const 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; } @@ -749,7 +751,7 @@ struct _GtkTreeEntry* wxListBox::GtkGetEntry(int n) const 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); @@ -767,7 +769,7 @@ wxClientData* wxListBox::DoGetItemClientObject( int n ) const 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); @@ -789,6 +791,7 @@ void wxListBox::DoSetItemClientObject( int n, wxClientData* clientData ) 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); @@ -797,8 +800,8 @@ void wxListBox::SetString( int n, const wxString &string ) 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 @@ -813,7 +816,7 @@ void wxListBox::SetString( int n, const wxString &string ) wxArrayString aItems; aItems.Add(label); - GtkInsertItems(aItems, &userdata, n); + GtkInsertItems(aItems, &userdata, (size_t)n); if (bWasSelected) wxListBox::GtkSetSelection(n, true, true); } @@ -839,11 +842,11 @@ wxString wxListBox::GetString( int n ) const 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 @@ -851,12 +854,12 @@ 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; } @@ -964,7 +967,7 @@ void wxListBox::GtkSetSelection(int n, const bool select, const bool blockEvent) 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)) @@ -1092,13 +1095,13 @@ wxSize wxListBox::DoGetBestSize() const // 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); diff --git a/src/gtk/radiobox.cpp b/src/gtk/radiobox.cpp index 283027982e..1e903f7fdd 100644 --- a/src/gtk/radiobox.cpp +++ b/src/gtk/radiobox.cpp @@ -65,7 +65,7 @@ static gint gtk_radiobox_keypress_callback( GtkWidget *widget, GdkEventKey *gdk_ 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)) ) { @@ -498,7 +498,7 @@ bool wxRadioBox::IsItemShown(int item) const return GTK_WIDGET_VISIBLE(GTK_WIDGET(button)); } -int wxRadioBox::GetCount() const +size_t wxRadioBox::GetCount() const { return m_boxes.GetCount(); } diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 8b61e05950..6558cf509b 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -7,7 +7,7 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/defs.h" +#include "wx/wxprec.h" #if wxUSE_CHOICE @@ -133,7 +133,7 @@ bool wxChoice::Create( wxWindow *parent, wxWindowID id, GtkWidget *menu = gtk_menu_new(); - for (int i = 0; i < n; i++) + for (size_t i = 0; i < (size_t)n; i++) { GtkAddHelper(menu, i, choices[i]); } @@ -167,9 +167,9 @@ int wxChoice::DoAppend( const wxString &item ) int wxChoice::DoInsert( const wxString &item, int pos ) { wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") ); - wxCHECK_MSG( (pos>=0) && (pos<=GetCount()), -1, wxT("invalid index")); + wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index")); - if (pos == GetCount()) + if ((size_t)pos == GetCount()) return DoAppend(item); GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ); @@ -181,7 +181,7 @@ int wxChoice::DoInsert( const wxString &item, int pos ) m_selection_hack++; } - return GtkAddHelper(menu, pos, item); + return GtkAddHelper(menu, (size_t)pos, item); } void wxChoice::DoSetItemClientData( int n, void* clientData ) @@ -262,10 +262,10 @@ void wxChoice::Delete( int n ) // VZ: apparently GTK+ doesn't have a built-in function to do it (not even // in 2.0), hence this dumb implementation -- still better than nothing - int i, - count = GetCount(); + int i; + size_t count = GetCount(); - wxCHECK_RET( n >= 0 && n < count, _T("invalid index in wxChoice::Delete") ); + wxCHECK_RET( IsValid(n), _T("invalid index in wxChoice::Delete") ); // if the item to delete is before the selection, and the selection is valid if ((n < m_selection_hack) && (m_selection_hack != wxNOT_FOUND)) @@ -287,7 +287,7 @@ void wxChoice::Delete( int n ) wxArrayString items; wxArrayPtrVoid itemsData; items.Alloc(count); - for ( i = 0; i < count; i++ ) + for ( i = 0; (size_t)i < count; i++ ) { if ( i != n ) { @@ -432,12 +432,12 @@ wxString wxChoice::GetString( int n ) const return wxEmptyString; } -int wxChoice::GetCount() const +size_t wxChoice::GetCount() const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid choice") ); GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) ); - int count = 0; + size_t count = 0; GList *child = menu_shell->children; while (child) { @@ -455,7 +455,7 @@ void wxChoice::SetSelection( int n ) gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp ); // set the local selection variable manually - if ((n >= 0) && (n < GetCount())) + if ((n >= 0) && ((size_t)n < GetCount())) { // a valid selection has been made m_selection_hack = n; @@ -498,9 +498,9 @@ void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style) } } -int wxChoice::GtkAddHelper(GtkWidget *menu, int pos, const wxString& item) +int wxChoice::GtkAddHelper(GtkWidget *menu, size_t pos, const wxString& item) { - wxCHECK_MSG((pos>=0) && (pos<=(int)m_clientList.GetCount()), -1, wxT("invalid index")); + wxCHECK_MSG(pos<=m_clientList.GetCount(), -1, wxT("invalid index")); GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) ); diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 5244048804..aa879cab6f 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -10,10 +10,10 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/combobox.h" - #if wxUSE_COMBOBOX +#include "wx/combobox.h" + #include "wx/settings.h" #include "wx/arrstr.h" #include "wx/intl.h" @@ -347,11 +347,11 @@ int wxComboBox::DoAppend( const wxString &item ) gtk_widget_show( list_item ); - const int count = GetCount(); + const size_t count = GetCount(); - if ( (int)m_clientDataList.GetCount() < count ) + if ( m_clientDataList.GetCount() < count ) m_clientDataList.Append( (wxObject*) NULL ); - if ( (int)m_clientObjectList.GetCount() < count ) + if ( m_clientObjectList.GetCount() < count ) m_clientObjectList.Append( (wxObject*) NULL ); EnableEvents(); @@ -368,10 +368,9 @@ int wxComboBox::DoInsert( const wxString &item, int pos ) wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid combobox") ); - int count = GetCount(); - wxCHECK_MSG( (pos >= 0) && (pos <= count), -1, wxT("invalid index") ); + wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index") ); - if (pos == count) + if ((size_t)pos == GetCount()) return Append(item); DisableEvents(); @@ -394,11 +393,11 @@ int wxComboBox::DoInsert( const wxString &item, int pos ) gtk_widget_show( list_item ); - count = GetCount(); + const size_t count = GetCount(); - if ( (int)m_clientDataList.GetCount() < count ) + if ( m_clientDataList.GetCount() < count ) m_clientDataList.Insert( pos, (wxObject*) NULL ); - if ( (int)m_clientObjectList.GetCount() < count ) + if ( m_clientObjectList.GetCount() < count ) m_clientObjectList.Insert( pos, (wxObject*) NULL ); EnableEvents(); @@ -455,7 +454,7 @@ void wxComboBox::Clear() DisableEvents(); GtkWidget *list = GTK_COMBO(m_widget)->list; - gtk_list_clear_items( GTK_LIST(list), 0, GetCount() ); + gtk_list_clear_items( GTK_LIST(list), 0, (int)GetCount() ); wxList::compatibility_iterator node = m_clientObjectList.GetFirst(); while (node) @@ -581,7 +580,7 @@ int wxComboBox::GetCurrentSelection() const } } - return -1; + return wxNOT_FOUND; } wxString wxComboBox::GetString( int n ) const @@ -626,14 +625,14 @@ wxString wxComboBox::GetStringSelection() const return wxEmptyString; } -int wxComboBox::GetCount() const +size_t wxComboBox::GetCount() const { wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid combobox") ); GtkWidget *list = GTK_COMBO(m_widget)->list; GList *child = GTK_LIST(list)->children; - int count = 0; + size_t count = 0; while (child) { count++; child = child->next; } return count; } @@ -798,7 +797,7 @@ void wxComboBox::Replace( long from, long to, const wxString& value ) wxCharBuffer buffer = wxConvUTF8.cWX2MB( value ); gtk_editable_insert_text( GTK_EDITABLE(entry), (const char*) buffer, strlen( (const char*) buffer ), &pos ); #else - gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.Length(), &pos ); + gtk_editable_insert_text( GTK_EDITABLE(entry), value.c_str(), value.length(), &pos ); #endif } diff --git a/src/gtk1/listbox.cpp b/src/gtk1/listbox.cpp index 8e307362d1..f22c1ad797 100644 --- a/src/gtk1/listbox.cpp +++ b/src/gtk1/listbox.cpp @@ -71,7 +71,7 @@ static gint wxlistbox_idle_callback( gpointer gdata ) // check that the items haven't been deleted from the listbox since we had // installed this callback wxListBox *lbox = data->m_listbox; - if ( data->m_item < lbox->GetCount() ) + if ( data->m_item < (int)lbox->GetCount() ) { lbox->SetFirstItem( data->m_item ); } @@ -583,7 +583,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) // code elsewhere supposes we have as many items in m_clientList as items // in the listbox - wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(), + wxASSERT_MSG( m_clientList.GetCount() == GetCount(), wxT("bug in client data management") ); InvalidateBestSize(); @@ -602,7 +602,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) { index = m_strings->Add( items[n] ); - if (index != GetCount()) + if (index != (int)GetCount()) { GtkAddItem( items[n], index ); wxList::compatibility_iterator node = m_clientList.Item( index ); @@ -638,7 +638,7 @@ void wxListBox::DoInsertItems(const wxArrayString& items, int pos) } } - wxASSERT_MSG( m_clientList.GetCount() == (size_t)GetCount(), + wxASSERT_MSG( m_clientList.GetCount() == GetCount(), wxT("bug in client data management") ); } @@ -652,7 +652,7 @@ int wxListBox::DoAppend( const wxString& item ) int index = m_strings->Add( item ); // only if not at the end anyway - if (index != GetCount()) + if (index != (int)GetCount()) { GtkAddItem( item, index ); @@ -773,7 +773,7 @@ void wxListBox::Clear() { wxCHECK_RET( m_list != NULL, wxT("invalid listbox") ); - gtk_list_clear_items( m_list, 0, GetCount() ); + gtk_list_clear_items( m_list, 0, (int)GetCount() ); if ( GTK_LIST(m_list)->last_focus_child != NULL ) { @@ -938,9 +938,9 @@ wxString wxListBox::GetString( int n ) const return wxEmptyString; } -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { - wxCHECK_MSG( m_list != NULL, -1, wxT("invalid listbox") ); + wxCHECK_MSG( m_list != NULL, 0, wxT("invalid listbox") ); GList *children = m_list->children; return g_list_length(children); @@ -1216,7 +1216,7 @@ wxSize wxListBox::DoGetBestSize() const int wLine; // Find the widest line - for(int i = 0; i < GetCount(); i++) { + for(size_t i = 0; i < GetCount(); i++) { wxString str(GetString(i)); GetTextExtent(str, &wLine, NULL); lbWidth = wxMax(lbWidth, wLine); diff --git a/src/gtk1/radiobox.cpp b/src/gtk1/radiobox.cpp index 156ca7c879..066daa51af 100644 --- a/src/gtk1/radiobox.cpp +++ b/src/gtk1/radiobox.cpp @@ -492,7 +492,7 @@ bool wxRadioBox::IsItemShown(int item) const return GTK_WIDGET_VISIBLE(GTK_WIDGET(button)); } -int wxRadioBox::GetCount() const +size_t wxRadioBox::GetCount() const { return m_boxes.GetCount(); } diff --git a/src/mac/carbon/choice.cpp b/src/mac/carbon/choice.cpp index 09edb09274..531ac02dee 100644 --- a/src/mac/carbon/choice.cpp +++ b/src/mac/carbon/choice.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -137,9 +137,9 @@ int wxChoice::DoAppend( const wxString& item ) 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 ); @@ -153,7 +153,7 @@ int wxChoice::DoInsert( const wxString& item, int 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 ); @@ -167,7 +167,7 @@ void wxChoice::Delete( int 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 ) ; } @@ -206,7 +206,7 @@ void wxChoice::SetSelection( int n ) // string list functions // ---------------------------------------------------------------------------- -int wxChoice::GetCount() const +size_t wxChoice::GetCount() const { return m_strings.GetCount() ; } @@ -218,8 +218,7 @@ int wxChoice::FindString( const wxString& s, bool bCase ) const 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 ; @@ -229,8 +228,7 @@ void wxChoice::SetString( int n, const wxString& 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] ; } @@ -240,16 +238,14 @@ wxString wxChoice::GetString( int n ) const // ---------------------------------------------------------------------------- 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]; } @@ -316,7 +312,7 @@ wxSize wxChoice::DoGetBestSize() const } // Find the widest line - for(int i = 0; i < GetCount(); i++) + for(size_t i = 0; i < GetCount(); i++) { wxString str( GetString( i ) ); @@ -333,7 +329,7 @@ wxSize wxChoice::DoGetBestSize() const 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 ) ; diff --git a/src/mac/carbon/combobox.cpp b/src/mac/carbon/combobox.cpp index 56238d61d6..754b1ea500 100644 --- a/src/mac/carbon/combobox.cpp +++ b/src/mac/carbon/combobox.cpp @@ -410,7 +410,7 @@ wxString wxComboBox::GetValue() const return result; } -int wxComboBox::GetCount() const +size_t wxComboBox::GetCount() const { return m_choice->GetCount() ; } diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index 3866099832..93701b90f8 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -60,7 +60,7 @@ static pascal void DataBrowserItemNotificationProc(ControlRef browser, DataBrows { 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() ); @@ -119,7 +119,7 @@ static pascal OSStatus ListBoxGetSetItemData(ControlRef browser, { 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 ) ) ; @@ -326,7 +326,7 @@ void wxListBox::FreeData() { 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 ); } @@ -347,7 +347,7 @@ void wxListBox::DoSetFirstItem(int 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() ) @@ -364,7 +364,7 @@ int wxListBox::DoAppend(const wxString& item) { InvalidateBestSize(); - int index = m_noItems ; + size_t index = m_noItems ; m_stringArray.Add( item ) ; m_dataArray.Add( NULL ); m_noItems++; @@ -377,9 +377,9 @@ int wxListBox::DoAppend(const wxString& item) 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] ) ; @@ -392,28 +392,28 @@ int wxListBox::FindString(const wxString& s, bool bCase) const { 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 ; } } } @@ -423,12 +423,12 @@ int wxListBox::FindString(const wxString& s, bool bCase) const 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 ; } } @@ -446,7 +446,7 @@ void wxListBox::Clear() 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 ) @@ -457,7 +457,7 @@ void wxListBox::DoSetSelection(int n, bool select) 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 ) ; @@ -465,8 +465,9 @@ bool wxListBox::IsSelected(int n) const 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]; } @@ -478,8 +479,7 @@ wxClientData *wxListBox::DoGetItemClientObject(int n) const 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") ) ; @@ -509,7 +509,7 @@ int wxListBox::GetSelection() const // 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] ; @@ -517,14 +517,14 @@ wxString wxListBox::GetString(int n) const 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 ) ; @@ -563,7 +563,7 @@ wxSize wxListBox::DoGetBestSize() const } // Find the widest line - for (int i = 0; i < GetCount(); i++) + for (size_t i = 0; i < GetCount(); i++) { wxString str( GetString( i ) ); @@ -581,7 +581,7 @@ wxSize wxListBox::DoGetBestSize() const &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 ); @@ -603,7 +603,7 @@ wxSize wxListBox::DoGetBestSize() const return wxSize( lbWidth, lbHeight ); } -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { return m_noItems; } @@ -737,7 +737,7 @@ bool wxListBox::MacIsSelected( int n ) const 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 ; diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 1fecf3f8db..020354b760 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -6,7 +6,7 @@ // Created: 1998-01-01 // RCS-ID: $Id$ // Copyright: (c) Stefan Csomor -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// //------------------------------------------------------------------------------------- @@ -101,7 +101,7 @@ bool wxRadioBox::Create( wxWindow *parent, int i; - m_noItems = n; + m_noItems = (size_t)n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; @@ -148,14 +148,13 @@ bool wxRadioBox::Create( wxWindow *parent, // 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(); @@ -285,11 +284,10 @@ void wxRadioBox::SetSelection(int item) // bool wxRadioBox::Show(bool show) { - int i; wxRadioButton *current; current = m_radioButtonCycle; - for (i=0; iShow( show ); current = current->NextInCycle(); @@ -389,7 +387,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) 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); @@ -479,7 +477,7 @@ wxSize wxRadioBox::DoGetBestSize() const 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); @@ -506,4 +504,4 @@ wxSize wxRadioBox::DoGetBestSize() const return wxSize( totWidth, totHeight ); } -#endif +#endif // wxUSE_RADIOBOX diff --git a/src/mac/classic/checklst.cpp b/src/mac/classic/checklst.cpp index ae436e163d..b0cd769cfc 100644 --- a/src/mac/classic/checklst.cpp +++ b/src/mac/classic/checklst.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////////// -// 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 @@ -13,7 +13,7 @@ // headers & declarations // ============================================================================ -#include "wx/defs.h" +#include "wx/wxprec.h" #if wxUSE_CHECKLISTBOX @@ -69,7 +69,7 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, list = (wxCheckListBox*) GetControlReference( (ControlHandle) GetListRefCon(listHandle) ); if ( list == NULL ) return ; - + GrafPtr savePort; GrafPtr grafPtr; RgnHandle savedClipRegion; @@ -78,9 +78,9 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, SetPort((**listHandle).port); grafPtr = (**listHandle).port ; // typecast our refCon - + // Calculate the cell rect. - + switch( message ) { case lInitMsg: break; @@ -95,13 +95,13 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, // 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() ) { @@ -109,45 +109,45 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, ::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 ); @@ -157,7 +157,7 @@ static pascal void wxMacCheckListDefinition( short message, Boolean isSelected, default : break ; } - SetPort(savePort); + SetPort(savePort); } extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ; @@ -203,13 +203,13 @@ bool wxCheckListBox::Create(wxWindow *parent, 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 @@ -217,26 +217,26 @@ bool wxCheckListBox::Create(wxWindow *parent, 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_checkBoxHeightMacGetRootWindow()) , &bounds , title , false , - kwxMacListWithVerticalScrollbar , 0 , 0, + kwxMacListWithVerticalScrollbar , 0 , 0, kControlListBoxProc , (long) this ) ; ::GetControlData( (ControlHandle) m_macControl , kControlNoPart , kControlListBoxListHandleTag , sizeof( ListHandle ) , (char*) &m_macList , &result ) ; @@ -273,7 +273,7 @@ bool wxCheckListBox::Create(wxWindow *parent, (**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 ) ; @@ -293,17 +293,17 @@ bool wxCheckListBox::Create(wxWindow *parent, 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; } // ---------------------------------------------------------------------------- @@ -312,7 +312,7 @@ bool wxCheckListBox::Create(wxWindow *parent, 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; @@ -320,7 +320,7 @@ bool wxCheckListBox::IsChecked(size_t item) const 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++ @@ -339,7 +339,7 @@ void wxCheckListBox::Check(size_t item, bool check) 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); @@ -352,7 +352,7 @@ int wxCheckListBox::DoAppend(const wxString& item) 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; @@ -365,7 +365,7 @@ void wxCheckListBox::DoInsertItems(const wxArrayString& items, int 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); } } @@ -377,7 +377,7 @@ void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData) size_t count = items.GetCount(); for ( size_t n = 0; n < count; n++ ) { - m_checks.Add(FALSE); + m_checks.Add(false); } } @@ -391,7 +391,7 @@ BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox) 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) { @@ -429,8 +429,8 @@ void wxCheckListBox::OnLeftClick(wxMouseEvent& 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()); diff --git a/src/mac/classic/choice.cpp b/src/mac/classic/choice.cpp index c608874704..d31d3e9b43 100644 --- a/src/mac/classic/choice.cpp +++ b/src/mac/classic/choice.cpp @@ -6,10 +6,10 @@ // 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 @@ -99,7 +99,7 @@ int wxChoice::DoAppend(const wxString& item) 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); @@ -114,7 +114,7 @@ int wxChoice::DoInsert(const wxString& item, int pos) 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); @@ -166,7 +166,7 @@ void wxChoice::SetSelection(int n) // string list functions // ---------------------------------------------------------------------------- -int wxChoice::GetCount() const +size_t wxChoice::GetCount() const { return m_strings.GetCount() ; } @@ -182,7 +182,7 @@ void wxChoice::SetString(int n, const wxString& s) 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] ; @@ -272,7 +272,7 @@ wxSize wxChoice::DoGetBestSize() const &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); } diff --git a/src/mac/classic/listbox.cpp b/src/mac/classic/listbox.cpp index 125b84b682..cdd1f889d3 100644 --- a/src/mac/classic/listbox.cpp +++ b/src/mac/classic/listbox.cpp @@ -9,6 +9,10 @@ // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// +#include "wx/wxprec.h" + +#if wxUSE_LISTBOX + #include "wx/app.h" #include "wx/listbox.h" #include "wx/button.h" @@ -304,7 +308,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, LSetDrawingMode( true , (ListHandle)m_macList ) ; - return TRUE; + return true; } wxListBox::~wxListBox() @@ -339,7 +343,7 @@ void wxListBox::FreeData() #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); } @@ -374,7 +378,7 @@ void wxListBox::DoSetFirstItem(int 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 @@ -397,7 +401,7 @@ int wxListBox::DoAppend(const wxString& item) { InvalidateBestSize(); - int index = m_noItems ; + size_t index = m_noItems ; m_stringArray.Add( item ) ; m_dataArray.Add( NULL ); m_noItems ++; @@ -439,7 +443,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) 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); @@ -458,26 +462,26 @@ int wxListBox::FindString(const wxString& s, bool bCase) const { 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 ; } } @@ -488,12 +492,12 @@ int wxListBox::FindString(const wxString& s, bool bCase) const 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 ; } } @@ -511,7 +515,7 @@ void wxListBox::Clear() 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 ) ; @@ -519,7 +523,7 @@ void wxListBox::DoSetSelection(int N, bool select) 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 ) ; @@ -527,7 +531,7 @@ bool wxListBox::IsSelected(int N) const 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]; @@ -540,7 +544,7 @@ wxClientData *wxListBox::DoGetItemClientObject(int N) const 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 @@ -588,14 +592,14 @@ wxString wxListBox::GetString(int N) const 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 ) ; @@ -647,7 +651,7 @@ wxSize wxListBox::DoGetBestSize() const &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); } @@ -667,7 +671,7 @@ wxSize wxListBox::DoGetBestSize() const return wxSize(lbWidth, lbHeight); } -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { return m_noItems; } @@ -692,7 +696,7 @@ public: 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); @@ -721,7 +725,7 @@ list = (wxListBox*)refCon; ::TextFont( kFontIDMonaco ) ; ::TextSize( 9 ); ::TextFace( 0 ) ; - DrawText(text, 0 , text.Length()); + DrawText(text, 0 , text.length()); } */ @@ -1017,3 +1021,5 @@ void wxListBox::OnChar(wxKeyEvent& event) } } } + +#endif // wxUSE_LISTBOX diff --git a/src/mac/classic/radiobox.cpp b/src/mac/classic/radiobox.cpp index 39bd6b2855..869d0c9b44 100644 --- a/src/mac/classic/radiobox.cpp +++ b/src/mac/classic/radiobox.cpp @@ -6,16 +6,18 @@ // 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" @@ -109,7 +111,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, int i; - m_noItems = n; + m_noItems = (size_t)n; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; @@ -153,14 +155,13 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, 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(); } @@ -310,13 +311,12 @@ void wxRadioBox::SetSelection(int item) bool wxRadioBox::Show(bool show) { - int i; wxRadioButton *current; wxControl::Show(show); current=m_radioButtonCycle; - for (i=0;iShow(show); current=current->NextInCycle(); @@ -385,7 +385,7 @@ void wxRadioBox::SetFocus() void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { - int i; + size_t i; wxRadioButton *current; // define the position @@ -423,7 +423,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) eachHeight[i] = (int)((3*eachHeight[i])/2); if (maxWidthGetClientWidget(); @@ -162,7 +162,7 @@ int wxComboBox::DoAppend(const wxString& item) 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); diff --git a/src/motif/listbox.cpp b/src/motif/listbox.cpp index 0f5deaca4d..8eba4cd13a 100644 --- a/src/motif/listbox.cpp +++ b/src/motif/listbox.cpp @@ -12,6 +12,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_LISTBOX + #ifdef __VMS #define XtParent XTPARENT #define XtDisplay XTDISPLAY @@ -87,7 +89,7 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id, validator, name ) ) return false; - m_noItems = n; + m_noItems = (size_t)n; m_backgroundColour = * wxWHITE; Widget parentWidget = (Widget) parent->GetClientWidget(); @@ -190,8 +192,9 @@ void wxListBox::DoSetFirstItem( int N ) { int count, length; - if (N < 0) + if (!IsValid(N)) return; + XtVaGetValues ((Widget) m_mainWidget, XmNvisibleItemCount, &count, XmNitemCount, &length, @@ -663,7 +666,7 @@ void wxListBox::ChangeForegroundColour() */ } -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { return m_noItems; } @@ -714,3 +717,5 @@ wxSize wxListBox::DoGetBestSize() const { return wxDoGetListBoxBestSize( (Widget)m_mainWidget, this ); } + +#endif // wxUSE_LISTBOX diff --git a/src/motif/radiobox.cpp b/src/motif/radiobox.cpp index 90e3cdd123..0eb64ebb3a 100644 --- a/src/motif/radiobox.cpp +++ b/src/motif/radiobox.cpp @@ -12,12 +12,12 @@ // 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" @@ -59,7 +59,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title, 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); @@ -197,8 +197,7 @@ void wxRadioBox::SetSelection(int n) 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); @@ -259,8 +258,7 @@ bool wxRadioBox::Enable(bool enable) 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; @@ -335,8 +333,7 @@ void wxRadioBox::ChangeFont(bool keepOriginalSize) { 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]; @@ -352,8 +349,7 @@ void wxRadioBox::ChangeBackgroundColour() 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]; @@ -369,8 +365,7 @@ void wxRadioBox::ChangeForegroundColour() { 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]; @@ -402,3 +397,5 @@ void wxRadioBoxCallback (Widget w, XtPointer clientData, event.SetEventObject(item); item->ProcessCommand (event); } + +#endif // wxUSE_RADIOBOX diff --git a/src/msw/checklst.cpp b/src/msw/checklst.cpp index 80e080f5d0..b40783e67a 100644 --- a/src/msw/checklst.cpp +++ b/src/msw/checklst.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: msw/checklst.cpp +// Name: src/msw/checklst.cpp // Purpose: implementation of wxCheckListBox class // Author: Vadim Zeitlin // Modified by: @@ -337,7 +337,7 @@ bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id, 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); @@ -521,7 +521,7 @@ int wxCheckListBox::DoHitTestItem(wxCoord x, wxCoord y) const MAKELPARAM(x, y) ); - return nItem >= m_noItems ? wxNOT_FOUND : nItem; + return nItem >= (int)m_noItems ? wxNOT_FOUND : nItem; } @@ -534,4 +534,3 @@ wxSize wxCheckListBox::DoGetBestSize() const } #endif - diff --git a/src/msw/choice.cpp b/src/msw/choice.cpp index e35fab7117..7c15b52d83 100644 --- a/src/msw/choice.cpp +++ b/src/msw/choice.cpp @@ -239,7 +239,7 @@ int wxChoice::DoAppend(const wxString& item) 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 ) @@ -258,7 +258,7 @@ int wxChoice::DoInsert(const wxString& item, int pos) 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() ) { @@ -326,9 +326,9 @@ void wxChoice::SetSelection(int n) // 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 @@ -336,8 +336,8 @@ 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) ) @@ -350,8 +350,8 @@ int wxChoice::FindString(const wxString& s, bool bCase) const //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; @@ -376,8 +376,7 @@ int wxChoice::FindString(const wxString& s, bool bCase) const 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 diff --git a/src/msw/listbox.cpp b/src/msw/listbox.cpp index 7abbf18e2b..d688e9ae92 100644 --- a/src/msw/listbox.cpp +++ b/src/msw/listbox.cpp @@ -250,7 +250,7 @@ WXDWORD wxListBox::MSWGetStyle(long style, WXDWORD *exstyle) const 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); @@ -258,7 +258,7 @@ void wxListBox::DoSetFirstItem(int N) 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 @@ -312,7 +312,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) ListBox_ResetContent(GetHwnd()); m_noItems = choices.GetCount(); - int i; + size_t i; for (i = 0; i < m_noItems; i++) { ListBox_AddString(GetHwnd(), choices[i]); @@ -328,7 +328,7 @@ void wxListBox::DoSetItems(const wxArrayString& choices, void** clientData) 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); @@ -384,7 +384,7 @@ void wxListBox::Free() #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); } @@ -393,8 +393,7 @@ void wxListBox::Free() 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() ) @@ -409,7 +408,7 @@ void wxListBox::DoSetSelection(int N, bool select) 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; @@ -422,7 +421,7 @@ wxClientData* wxListBox::DoGetItemClientObject(int n) const 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); @@ -435,7 +434,7 @@ void wxListBox::DoSetItemClientObject(int n, wxClientData* clientData) 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 @@ -507,7 +506,7 @@ int wxListBox::GetSelection() const // 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); @@ -522,7 +521,7 @@ wxString wxListBox::GetString(int N) const 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(); @@ -554,7 +553,7 @@ wxListBox::DoInsertItems(const wxArrayString& items, int pos) 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 @@ -564,7 +563,7 @@ int wxListBox::DoListHitTest(const wxPoint& point) const 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 @@ -581,7 +580,7 @@ void wxListBox::SetString(int N, const wxString& s) 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); @@ -610,7 +609,7 @@ void wxListBox::SetString(int N, const wxString& s) InvalidateBestSize(); } -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { return m_noItems; } @@ -639,7 +638,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) 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) @@ -659,7 +658,7 @@ void wxListBox::SetHorizontalExtent(const wxString& s) 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; @@ -681,7 +680,7 @@ wxSize wxListBox::DoGetBestSize() const // 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); diff --git a/src/msw/radiobox.cpp b/src/msw/radiobox.cpp index 795df4f865..d8f693b089 100644 --- a/src/msw/radiobox.cpp +++ b/src/msw/radiobox.cpp @@ -269,8 +269,8 @@ bool wxRadioBox::MSWCommand(WXUINT cmd, WXWORD id) 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]) ) { @@ -323,7 +323,7 @@ void wxRadioBox::SendNotificationEvent() // simple accessors // ---------------------------------------------------------------------------- -int wxRadioBox::GetCount() const +size_t wxRadioBox::GetCount() const { return m_radioButtons->GetCount(); } @@ -432,8 +432,8 @@ wxSize wxRadioBox::GetMaxButtonSize() const // 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 ) @@ -565,8 +565,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) 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 @@ -576,7 +576,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) { // 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 diff --git a/src/msw/wince/checklst.cpp b/src/msw/wince/checklst.cpp index 56b519b537..0c4a31c527 100644 --- a/src/msw/wince/checklst.cpp +++ b/src/msw/wince/checklst.cpp @@ -156,8 +156,7 @@ void wxCheckListBox::OnSize(wxSizeEvent& event) 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) ) { @@ -171,7 +170,7 @@ void wxCheckListBox::Delete(int 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); @@ -179,7 +178,7 @@ bool wxCheckListBox::IsChecked(size_t uiIndex) const 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) @@ -190,7 +189,7 @@ void wxCheckListBox::Check(size_t uiIndex, bool bCheck) void wxCheckListBox::Clear() { - int n = GetCount(); + int n = (int)GetCount(); while ( n > 0 ) { @@ -204,15 +203,15 @@ void wxCheckListBox::Clear() _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) @@ -225,7 +224,7 @@ int wxCheckListBox::GetSelection() const 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) @@ -253,7 +252,7 @@ bool wxCheckListBox::IsSelected(int n) const 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()); @@ -263,7 +262,7 @@ void wxCheckListBox::SetString(int n, const wxString& s) int wxCheckListBox::DoAppend(const wxString& item) { - int n = GetCount(); + int n = (int)GetCount(); LVITEM newItem; wxZeroMemory(newItem); newItem.iItem = n; @@ -286,7 +285,7 @@ wxClientData* wxCheckListBox::DoGetItemClientObject(int n) const 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++ ) diff --git a/src/msw/wince/choicece.cpp b/src/msw/wince/choicece.cpp index fa7426f1fe..fba1e4d019 100644 --- a/src/msw/wince/choicece.cpp +++ b/src/msw/wince/choicece.cpp @@ -24,18 +24,17 @@ #pragma hdrstop #endif +#if wxUSE_CHOICE && defined(__SMARTPHONE__) && defined(__WXWINCE__) + #ifndef WX_PRECOMP #include "wx/choice.h" + #include + #include "wx/msw/missing.h" + #include "wx/msw/winundef.h" #endif #include "wx/spinbutt.h" // for wxSpinnerBestSize -#include -#include "wx/msw/missing.h" -#include "wx/msw/winundef.h" - -#if wxUSE_CHOICE && defined(__SMARTPHONE__) && defined(__WXWINCE__) - #if wxUSE_EXTENDED_RTTI // TODO #else @@ -349,7 +348,7 @@ int wxChoice::DoAppend(const wxString& item) 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 ) @@ -362,7 +361,7 @@ int wxChoice::DoInsert(const wxString& item, int pos) 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() ) { @@ -409,9 +408,9 @@ void wxChoice::SetSelection(int n) // 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 @@ -428,7 +427,7 @@ 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 diff --git a/src/os2/checklst.cpp b/src/os2/checklst.cpp index 45004b7486..3bb67b387b 100644 --- a/src/os2/checklst.cpp +++ b/src/os2/checklst.cpp @@ -272,7 +272,7 @@ wxCheckListBox::wxCheckListBox ( wxWindow* pParent, 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); @@ -408,7 +408,7 @@ void wxCheckListBox::OnLeftClick ( wxMouseEvent& rEvent ) 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 diff --git a/src/os2/choice.cpp b/src/os2/choice.cpp index cea4402332..a6264e0f8d 100644 --- a/src/os2/choice.cpp +++ b/src/os2/choice.cpp @@ -12,8 +12,6 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" -#include "wx/defs.h" - #if wxUSE_CHOICE #ifndef WX_PRECOMP @@ -125,19 +123,16 @@ int wxChoice::DoAppend( 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; @@ -151,11 +146,9 @@ int wxChoice::DoInsert( 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 @@ -189,9 +182,9 @@ void wxChoice::SetSelection( // 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 ) @@ -316,21 +309,18 @@ wxSize wxChoice::DoGetBestSize() const // // 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; } @@ -345,11 +335,7 @@ wxSize wxChoice::DoGetBestSize() const // // The combobox should be larger than the widest string // - wxGetCharSize( GetHWND() - ,&nCx - ,&nCy - ,&vFont - ); + wxGetCharSize( GetHWND(), &nCx, &nCy, &vFont ); nChoiceWidth += 5 * nCx; // @@ -411,7 +397,7 @@ void wxChoice::Free() { if (HasClientObjectData()) { - size_t nCount = GetCount(); + const size_t nCount = GetCount(); for (size_t n = 0; n < nCount; n++) { diff --git a/src/os2/listbox.cpp b/src/os2/listbox.cpp index d5e6bc01fa..bdc00bfefe 100644 --- a/src/os2/listbox.cpp +++ b/src/os2/listbox.cpp @@ -12,6 +12,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_LISTBOX + #include "wx/window.h" #include "wx/os2/private.h" @@ -32,8 +34,6 @@ #include "wx/dynarray.h" #include "wx/log.h" -#if wxUSE_LISTBOX - #if wxUSE_OWNER_DRAWN #include "wx/ownerdrw.h" #endif @@ -100,17 +100,15 @@ bool wxListBox::Create( 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; @@ -227,7 +225,7 @@ bool wxListBox::Create( wxListBox::~wxListBox() { #if wxUSE_OWNER_DRAWN - size_t lUiCount = m_aItems.Count(); + size_t lUiCount = m_aItems.Count(); while (lUiCount-- != 0) { @@ -246,21 +244,17 @@ void wxListBox::SetupColours() // 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 @@ -277,17 +271,16 @@ void wxListBox::Delete( 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++; @@ -307,14 +300,11 @@ int wxListBox::DoAppend( 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) { @@ -322,9 +312,8 @@ void wxListBox::DoSetItems( } ::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 @@ -353,7 +342,7 @@ void wxListBox::DoSetItems( // // 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); @@ -369,7 +358,7 @@ void wxListBox::DoSetItems( void wxListBox::Clear() { #if wxUSE_OWNER_DRAWN - size_t lUiCount = m_aItems.Count(); + size_t lUiCount = m_aItems.Count(); while (lUiCount-- != 0) { @@ -391,12 +380,9 @@ void wxListBox::Clear() 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 @@ -407,11 +393,9 @@ void wxListBox::DoSetSelection( 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; @@ -430,39 +414,27 @@ bool wxListBox::IsSelected( 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 @@ -486,8 +458,8 @@ bool wxListBox::HasMultipleSelection() const int wxListBox::GetSelections( wxArrayInt& raSelections ) const { - int nCount = 0; - LONG lItem; + int nCount = 0; + LONG lItem; raSelections.Empty(); @@ -561,15 +533,13 @@ int wxListBox::GetSelection() const )); } // 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)); @@ -581,25 +551,22 @@ wxString wxListBox::GetString( 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()); @@ -613,20 +580,17 @@ void wxListBox::DoInsertItems( } } // 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); @@ -680,7 +644,7 @@ void wxListBox::SetString( #endif //USE_OWNER_DRAWN } // end of wxListBox::SetString -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { return m_nNumItems; } @@ -694,20 +658,17 @@ wxSize wxListBox::DoGetBestSize() const // // 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; } @@ -729,7 +690,7 @@ wxSize wxListBox::DoGetBestSize() const ); 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 @@ -767,9 +728,9 @@ bool wxListBox::OS2Command( vEvent.SetEventObject(this); - wxArrayInt aSelections; - int n; - int nCount = GetSelections(aSelections); + wxArrayInt aSelections; + int n; + int nCount = GetSelections(aSelections); if (nCount > 0) { @@ -800,9 +761,7 @@ bool wxListBox::OS2Command( // #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE (1) -long wxListBox::OS2OnMeasure( - WXMEASUREITEMSTRUCT* pItem -) +long wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT* pItem) { if (!pItem) pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM; @@ -944,4 +903,4 @@ bool wxListBox::OS2OnDraw ( #endif // ndef for wxUSE_OWNER_DRAWN -#endif // ndef for wxUSE_LISTBOX +#endif // wxUSE_LISTBOX diff --git a/src/os2/radiobox.cpp b/src/os2/radiobox.cpp index fa60f8f8de..7730459f64 100644 --- a/src/os2/radiobox.cpp +++ b/src/os2/radiobox.cpp @@ -12,6 +12,8 @@ // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" +#if wxUSE_RADIOBOX + #ifndef WX_PRECOMP #include #include "wx/wxchar.h" @@ -79,7 +81,7 @@ wxRadioBox::~wxRadioBox() 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); @@ -94,20 +96,16 @@ wxRadioBox::~wxRadioBox() 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++) { @@ -117,18 +115,16 @@ bool wxRadioBox::ContainsHWND( 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); @@ -136,23 +132,21 @@ bool wxRadioBox::Create( 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(); @@ -184,7 +178,7 @@ bool wxRadioBox::Create( // // 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]; @@ -412,14 +406,14 @@ void wxRadioBox::DoSetSize( 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) { @@ -525,18 +519,16 @@ bool wxRadioBox::Enable(int nItem, bool bEnable) 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 @@ -550,13 +542,13 @@ wxString wxRadioBox::GetLabel(int nItem) const 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) { @@ -595,7 +587,7 @@ int wxRadioBox::GetSelection() const void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const { - RECT vRect; + RECT vRect; vRect.xLeft = -1; vRect.xRight = -1; @@ -603,14 +595,10 @@ void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const 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; @@ -701,7 +689,7 @@ bool wxRadioBox::OS2Command( WXUINT uCmd, 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])) { @@ -750,9 +738,7 @@ void wxRadioBox::SetFocus() } } // end of wxRadioBox::SetFocus -bool wxRadioBox::SetFont( - const wxFont& rFont -) +bool wxRadioBox::SetFont(const wxFont& rFont) { if (!wxControl::SetFont(rFont)) { @@ -764,13 +750,11 @@ bool wxRadioBox::SetFont( // // 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; @@ -814,14 +798,12 @@ bool wxRadioBox::SetStringSelection(const wxString& rsStr) 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); } @@ -959,3 +941,5 @@ MRESULT EXPENTRY wxRadioBoxWndProc( HWND hWnd, (MPARAM)lParam ) ); } // end of wxRadioBoxWndProc + +#endif // wxUSE_RADIOBOX diff --git a/src/palmos/choice.cpp b/src/palmos/choice.cpp index ce5eedf274..b5ff3ed5ee 100644 --- a/src/palmos/choice.cpp +++ b/src/palmos/choice.cpp @@ -188,7 +188,7 @@ void wxChoice::SetSelection(int n) // string list functions // ---------------------------------------------------------------------------- -int wxChoice::GetCount() const +size_t wxChoice::GetCount() const { return 0; } diff --git a/src/palmos/listbox.cpp b/src/palmos/listbox.cpp index 2ee8226dde..7302ebdaf0 100644 --- a/src/palmos/listbox.cpp +++ b/src/palmos/listbox.cpp @@ -110,7 +110,7 @@ public: 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); @@ -254,9 +254,9 @@ void wxListBox::SetString(int N, const wxString& s) { } -int wxListBox::GetCount() const +size_t wxListBox::GetCount() const { - return m_noItems; + return 0; } // ---------------------------------------------------------------------------- diff --git a/src/palmos/radiobox.cpp b/src/palmos/radiobox.cpp index 5fea32f9bd..03b015e38c 100644 --- a/src/palmos/radiobox.cpp +++ b/src/palmos/radiobox.cpp @@ -112,7 +112,7 @@ void wxRadioBox::Init() m_size = wxSize(0,0); } -int wxRadioBox::GetCount() const +size_t wxRadioBox::GetCount() const { return m_radios.GetCount(); } @@ -238,12 +238,12 @@ void wxRadioBox::DoMoveWindow(int x, int y, int width, int height) 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++ ) @@ -327,8 +327,8 @@ void wxRadioBox::SetFocus() // Enable all subcontrols bool wxRadioBox::Enable(bool enable) { - for(int i=0; i 0 ) { wxListBox::SetSelection(0); } @@ -798,7 +798,7 @@ void wxComboBox::Clear() 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); @@ -806,21 +806,21 @@ void wxComboBox::Delete(int n) 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); } @@ -832,7 +832,7 @@ int wxComboBox::FindString(const wxString& s, bool bCase) const 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)); @@ -859,9 +859,9 @@ int wxComboBox::DoAppend(const wxString& item) 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); diff --git a/src/univ/listbox.cpp b/src/univ/listbox.cpp index 58917edc04..9b26f6c614 100644 --- a/src/univ/listbox.cpp +++ b/src/univ/listbox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: univ/listbox.cpp +// Name: src/univ/listbox.cpp // Purpose: wxListBox implementation // Author: Vadim Zeitlin // Modified by: @@ -327,7 +327,7 @@ void wxListBox::Clear() 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 @@ -574,7 +574,7 @@ void wxListBox::UpdateScrollbars() 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; @@ -913,8 +913,8 @@ void wxListBox::SetCurrentItem(int n) 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; @@ -937,13 +937,13 @@ bool wxListBox::FindItem(const wxString& prefix, bool strictlyAfter) 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 ) { @@ -1055,8 +1055,8 @@ void wxListBox::ExtendSelection(int itemTo) SetSelection(n); } - int count = GetCount(); - for ( ; n < count; n++ ) + size_t count = GetCount(); + for ( ; n < (int)count; n++ ) { Deselect(n); } @@ -1230,7 +1230,7 @@ int wxStdListboxInputHandler::FixItemIndex(const wxListBox *lbox, // 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; @@ -1241,7 +1241,7 @@ int wxStdListboxInputHandler::FixItemIndex(const wxListBox *lbox, bool wxStdListboxInputHandler::IsValidIndex(const wxListBox *lbox, int item) { - return item >= 0 && item < lbox->GetCount(); + return item >= 0 && (size_t)item < lbox->GetCount(); } wxControlAction diff --git a/src/univ/radiobox.cpp b/src/univ/radiobox.cpp index 6a23d3d34b..a01ada44bd 100644 --- a/src/univ/radiobox.cpp +++ b/src/univ/radiobox.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: univ/radiobox.cpp +// Name: src/univ/radiobox.cpp // Purpose: wxRadioBox implementation // Author: Vadim Zeitlin // Modified by: @@ -335,7 +335,7 @@ bool wxRadioBox::Enable(bool enable) 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); @@ -350,7 +350,7 @@ bool wxRadioBox::Show(bool show) 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); @@ -375,7 +375,7 @@ void wxRadioBox::DoSetToolTip(wxToolTip *tooltip) 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) @@ -395,7 +395,7 @@ wxSize wxRadioBox::GetMaxButtonSize() const 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); @@ -442,8 +442,8 @@ void wxRadioBox::DoMoveWindow(int x0, int y0, int width, int 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); @@ -523,4 +523,3 @@ bool wxRadioBox::OnKeyDown(wxKeyEvent& event) } #endif // wxUSE_RADIOBOX - -- 2.45.2