X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2eb10e2a17a02acaaa32a41304243999f3a862a1..a703012aedeb8064c8294c6aeeea95e6950ad170:/include/wx/selstore.h diff --git a/include/wx/selstore.h b/include/wx/selstore.h index 8ddb73be18..94ce566b88 100644 --- a/include/wx/selstore.h +++ b/include/wx/selstore.h @@ -5,7 +5,7 @@ // Modified by: // Created: 08.06.03 (extracted from src/generic/listctrl.cpp) // RCS-ID: $Id$ -// Copyright: (c) 2000-2003 Vadim Zeitlin +// Copyright: (c) 2000-2003 Vadim Zeitlin // Licence: wxWindows licence /////////////////////////////////////////////////////////////////////////////// @@ -18,11 +18,12 @@ // wxSelectedIndices is just a sorted array of indices // ---------------------------------------------------------------------------- -inline int CMPFUNC_CONV wxSizeTCmpFn(size_t n1, size_t n2) { return n1 - n2; } +inline int CMPFUNC_CONV wxUIntCmp(unsigned n1, unsigned n2) +{ + return (int)(n1 - n2); +} -WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_LONG(size_t, - wxSizeTCmpFn, - wxSelectedIndices); +WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_INT(unsigned, wxUIntCmp, wxSelectedIndices); // ---------------------------------------------------------------------------- // wxSelectionStore is used to store the selected items in the virtual @@ -36,43 +37,43 @@ WX_DEFINE_SORTED_EXPORTED_ARRAY_CMP_LONG(size_t, // individual items) without changing its API. // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxSelectionStore +class WXDLLIMPEXP_CORE wxSelectionStore { public: - wxSelectionStore() : m_itemsSel(wxSizeTCmpFn) { Init(); } + wxSelectionStore() : m_itemsSel(wxUIntCmp) { Init(); } // set the total number of items we handle - void SetItemCount(size_t count) { m_count = count; } + void SetItemCount(unsigned count); // special case of SetItemCount(0) - void Clear() { m_itemsSel.Clear(); m_count = 0; m_defaultState = FALSE; } + void Clear() { m_itemsSel.Clear(); m_count = 0; m_defaultState = false; } // must be called when a new item is inserted/added - void OnItemAdd(size_t WXUNUSED(item)) { wxFAIL_MSG( _T("TODO") ); } + void OnItemAdd(unsigned WXUNUSED(item)) { wxFAIL_MSG( wxT("TODO") ); } // must be called when an item is deleted - void OnItemDelete(size_t item); + void OnItemDelete(unsigned item); // select one item, use SelectRange() insted if possible! // // returns true if the items selection really changed - bool SelectItem(size_t item, bool select = TRUE); + bool SelectItem(unsigned item, bool select = true); - // select the range of items + // select the range of items (inclusive) // // return true and fill the itemsChanged array with the indices of items // which have changed state if "few" of them did, otherwise return false // (meaning that too many items changed state to bother counting them // individually) - bool SelectRange(size_t itemFrom, size_t itemTo, - bool select = TRUE, + bool SelectRange(unsigned itemFrom, unsigned itemTo, + bool select = true, wxArrayInt *itemsChanged = NULL); // return true if the given item is selected - bool IsSelected(size_t item) const; + bool IsSelected(unsigned item) const; // return the total number of selected items - size_t GetSelectedCount() const + unsigned GetSelectedCount() const { return m_defaultState ? m_count - m_itemsSel.GetCount() : m_itemsSel.GetCount(); @@ -80,12 +81,12 @@ public: private: // (re)init - void Init() { m_defaultState = FALSE; } + void Init() { m_defaultState = false; } // the total number of items we handle - size_t m_count; + unsigned m_count; - // the default state: normally, FALSE (i.e. off) but maybe set to TRUE if + // the default state: normally, false (i.e. off) but maybe set to true if // there are more selected items than non selected ones - this allows to // handle selection of all items efficiently bool m_defaultState; @@ -93,9 +94,8 @@ private: // the array of items whose selection state is different from default wxSelectedIndices m_itemsSel; - DECLARE_NO_COPY_CLASS(wxSelectionStore) + wxDECLARE_NO_COPY_CLASS(wxSelectionStore); }; - #endif // _WX_SELSTORE_H_