Moved some methods/classes inside COMPATIBILITY_2_4.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21616 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
2ea4a2f552
commit
ba8c160144
@ -21,7 +21,11 @@ versions, please update your code to not use them.
|
||||
- wxList::Number, First, Last, Nth: use GetCount, GetFirst/Last, Item instead
|
||||
- wxNode::Next, Previous, Data: use GetNext, GetPrevious, GetData instead
|
||||
- wxListBase::operator wxList&(): use typesafe lists instead
|
||||
- wxTheFontMapper, use wxFontMapper::Get() instead
|
||||
- wxTheFontMapper: use wxFontMapper::Get() instead
|
||||
- wxStringHashTable: use wxHashMap instead
|
||||
- wxHashTableLong: use wxHashMap instead
|
||||
- wxArrayString::GetStringArray: no replacement
|
||||
- wxArrayString::Remove(index, count): use RemoveAt instead
|
||||
|
||||
|
||||
OTHER CHANGES
|
||||
|
@ -22,6 +22,7 @@
|
||||
|
||||
#include "wx/help.h"
|
||||
|
||||
#include "wx/hashmap.h"
|
||||
#if wxUSE_BMPBUTTON
|
||||
#include "wx/bmpbuttn.h"
|
||||
#endif
|
||||
@ -140,6 +141,9 @@ private:
|
||||
static wxHelpProvider *ms_helpProvider;
|
||||
};
|
||||
|
||||
WX_DECLARE_HASH_MAP( long, wxString, wxIntegerHash, wxIntegerEqual,
|
||||
wxLongToStringHashMap );
|
||||
|
||||
// wxSimpleHelpProvider is an implementation of wxHelpProvider which supports
|
||||
// only plain text help strings and shows the string associated with the
|
||||
// control (if any) in a tooltip
|
||||
@ -156,8 +160,8 @@ public:
|
||||
protected:
|
||||
// we use 2 hashes for storing the help strings associated with windows
|
||||
// and the ids
|
||||
wxStringHashTable m_hashWindows,
|
||||
m_hashIds;
|
||||
wxLongToStringHashMap m_hashWindows,
|
||||
m_hashIds;
|
||||
};
|
||||
|
||||
// wxHelpControllerHelpProvider is an implementation of wxHelpProvider which supports
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "wx/filesys.h"
|
||||
|
||||
class WXDLLIMPEXP_BASE wxHashTableLong;
|
||||
class WXDLLIMPEXP_BASE wxLongToLongHashMap;
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
// wxZipFSHandler
|
||||
@ -45,7 +45,7 @@ class WXDLLIMPEXP_BASE wxZipFSHandler : public wxFileSystemHandler
|
||||
void *m_Archive;
|
||||
wxString m_Pattern, m_BaseDir, m_ZipFile;
|
||||
bool m_AllowDirs, m_AllowFiles;
|
||||
wxHashTableLong *m_DirsFound;
|
||||
wxLongToLongHashMap *m_DirsFound;
|
||||
|
||||
wxString DoFind();
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
#pragma interface "grid.h"
|
||||
#endif
|
||||
|
||||
#include "wx/hash.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/panel.h"
|
||||
#include "wx/scrolwin.h"
|
||||
#include "wx/string.h"
|
||||
@ -80,6 +80,9 @@ class WXDLLEXPORT wxComboBox;
|
||||
class WXDLLEXPORT wxTextCtrl;
|
||||
class WXDLLEXPORT wxSpinCtrl;
|
||||
|
||||
WX_DECLARE_EXPORTED_HASH_MAP( long, long, wxIntegerHash, wxIntegerEqual,
|
||||
wxLongToLongHashMap );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// macros
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -1759,8 +1762,8 @@ protected:
|
||||
|
||||
// if a column has a minimal width, it will be the value for it in this
|
||||
// hash table
|
||||
wxHashTableLong m_colMinWidths,
|
||||
m_rowMinHeights;
|
||||
wxLongToLongHashMap m_colMinWidths,
|
||||
m_rowMinHeights;
|
||||
|
||||
// get the minimal width of the given column/row
|
||||
int GetColMinimalWidth(int col) const;
|
||||
|
@ -72,6 +72,8 @@ private:
|
||||
DECLARE_NO_COPY_CLASS(wxHashTableBase)
|
||||
};
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// a hash table which stores longs
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -143,6 +145,8 @@ private:
|
||||
DECLARE_NO_COPY_CLASS(wxStringHashTable)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// for compatibility only
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -305,5 +309,23 @@ private:
|
||||
#define WX_DECLARE_USER_EXPORTED_HASH(el, list, hash, usergoo) \
|
||||
_WX_DECLARE_HASH(el, list, hash, class usergoo)
|
||||
|
||||
// delete all hash elements
|
||||
//
|
||||
// NB: the class declaration of the hash elements must be visible from the
|
||||
// place where you use this macro, otherwise the proper destructor may not
|
||||
// be called (a decent compiler should give a warning about it, but don't
|
||||
// count on it)!
|
||||
#define WX_CLEAR_HASH_TABLE(array) \
|
||||
{ \
|
||||
(array).BeginFind(); \
|
||||
wxNode* it = (array).Next(); \
|
||||
while( it ) \
|
||||
{ \
|
||||
delete it->GetData(); \
|
||||
it = (array).Next(); \
|
||||
} \
|
||||
(array).Clear(); \
|
||||
}
|
||||
|
||||
#endif
|
||||
// _WX_HASH_H__
|
||||
|
@ -1027,12 +1027,19 @@ public:
|
||||
// from the array (operator[] or Item() method), a reference is returned.
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int WXDLLIMPEXP_BASE wxStringSortAscending(wxString*, wxString*);
|
||||
int WXDLLIMPEXP_BASE wxStringSortDescending(wxString*, wxString*);
|
||||
|
||||
class WXDLLIMPEXP_BASE wxArrayString
|
||||
{
|
||||
public:
|
||||
// type of function used by wxArrayString::Sort()
|
||||
typedef int (*CompareFunction)(const wxString& first,
|
||||
const wxString& second);
|
||||
// type of function used by wxArrayString::Sort(), for compatibility with
|
||||
// wxArray
|
||||
typedef int (*CompareFunction2)(wxString* first,
|
||||
wxString* second);
|
||||
|
||||
// constructors and destructor
|
||||
// default ctor
|
||||
@ -1095,11 +1102,13 @@ public:
|
||||
return Item(Count() - 1);
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
// return a wxString[], useful for the controls which
|
||||
// take one in their ctor. You must delete[] it yourself
|
||||
// once you are done with it. Will return NULL if the
|
||||
// ArrayString was empty.
|
||||
wxString* GetStringArray() const;
|
||||
#endif
|
||||
|
||||
// item management
|
||||
// Search the element in the array, starting from the beginning if
|
||||
@ -1117,8 +1126,10 @@ public:
|
||||
// remove first item matching this value
|
||||
void Remove(const wxChar *sz);
|
||||
// remove item by index
|
||||
void Remove(size_t nIndex, size_t nRemove = 1);
|
||||
void RemoveAt(size_t nIndex, size_t nRemove = 1) { Remove(nIndex, nRemove); }
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
void Remove(size_t nIndex, size_t nRemove = 1) { RemoveAt(nIndex, nRemove); }
|
||||
#endif
|
||||
void RemoveAt(size_t nIndex, size_t nRemove = 1);
|
||||
|
||||
// sorting
|
||||
// sort array elements in alphabetical order (or reversed alphabetical
|
||||
@ -1126,6 +1137,7 @@ public:
|
||||
void Sort(bool reverseOrder = FALSE);
|
||||
// sort array elements using specified comparaison function
|
||||
void Sort(CompareFunction compareFunction);
|
||||
void Sort(CompareFunction2 compareFunction);
|
||||
|
||||
// comparison
|
||||
// compare two arrays case sensitively
|
||||
|
@ -409,7 +409,7 @@ void wxSplitPath(wxArrayString& aParts, const wxChar *sz)
|
||||
if ( aParts.IsEmpty() )
|
||||
wxLogWarning(_("'%s' has extra '..', ignored."), sz);
|
||||
else
|
||||
aParts.Remove(aParts.Count() - 1);
|
||||
aParts.RemoveAt(aParts.Count() - 1);
|
||||
|
||||
strCurrent.Empty();
|
||||
}
|
||||
|
@ -326,30 +326,34 @@ wxHelpProvider::~wxHelpProvider()
|
||||
|
||||
wxString wxSimpleHelpProvider::GetHelp(const wxWindowBase *window)
|
||||
{
|
||||
bool wasFound;
|
||||
wxString text = m_hashWindows.Get((long)window, &wasFound);
|
||||
if ( !wasFound )
|
||||
text = m_hashIds.Get(window->GetId());
|
||||
wxLongToStringHashMap::iterator it = m_hashWindows.find((long)window);
|
||||
|
||||
return text;
|
||||
if ( it == m_hashWindows.end() )
|
||||
{
|
||||
it = m_hashIds.find(window->GetId());
|
||||
if ( it == m_hashIds.end() )
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
return it->second;
|
||||
}
|
||||
|
||||
void wxSimpleHelpProvider::AddHelp(wxWindowBase *window, const wxString& text)
|
||||
{
|
||||
m_hashWindows.Delete((long)window);
|
||||
m_hashWindows.Put((long)window, text);
|
||||
m_hashWindows.erase((long)window);
|
||||
m_hashWindows[(long)window] = text;
|
||||
}
|
||||
|
||||
void wxSimpleHelpProvider::AddHelp(wxWindowID id, const wxString& text)
|
||||
{
|
||||
m_hashIds.Delete((long)id);
|
||||
m_hashIds.Put(id, text);
|
||||
m_hashIds.erase((long)id);
|
||||
m_hashIds[id] = text;
|
||||
}
|
||||
|
||||
// removes the association
|
||||
void wxSimpleHelpProvider::RemoveHelp(wxWindowBase* window)
|
||||
{
|
||||
m_hashWindows.Delete((long)window);
|
||||
m_hashWindows.erase((long)window);
|
||||
}
|
||||
|
||||
bool wxSimpleHelpProvider::ShowHelp(wxWindowBase *window)
|
||||
|
@ -1140,7 +1140,7 @@ void wxFileName::InsertDir( int before, const wxString &dir )
|
||||
|
||||
void wxFileName::RemoveDir( int pos )
|
||||
{
|
||||
m_dirs.Remove( (size_t)pos );
|
||||
m_dirs.RemoveAt( (size_t)pos );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/hash.h"
|
||||
#include "wx/hashmap.h"
|
||||
#include "wx/filesys.h"
|
||||
#include "wx/zipstrm.h"
|
||||
#include "wx/fs_zip.h"
|
||||
@ -38,6 +38,8 @@
|
||||
#include "unzip.h"
|
||||
#endif
|
||||
|
||||
WX_DECLARE_EXPORTED_HASH_MAP( long, long, wxIntegerHash, wxIntegerEqual,
|
||||
wxLongToLongHashMap );
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxZipFSHandler
|
||||
@ -165,7 +167,7 @@ wxString wxZipFSHandler::FindFirst(const wxString& spec, int flags)
|
||||
if (m_AllowDirs)
|
||||
{
|
||||
delete m_DirsFound;
|
||||
m_DirsFound = new wxHashTableLong();
|
||||
m_DirsFound = new wxLongToLongHashMap();
|
||||
}
|
||||
return DoFind();
|
||||
}
|
||||
@ -203,9 +205,10 @@ wxString wxZipFSHandler::DoFind()
|
||||
{
|
||||
long key = 0;
|
||||
for (size_t i = 0; i < dir.Length(); i++) key += (wxUChar)dir[i];
|
||||
if (m_DirsFound->Get(key) == wxNOT_FOUND)
|
||||
wxLongToLongHashMap::iterator it = m_DirsFound->find(key);
|
||||
if (it == m_DirsFound->end())
|
||||
{
|
||||
m_DirsFound->Put(key, 1);
|
||||
m_DirsFound[key] = 1;
|
||||
filename = dir.AfterLast(wxT('/'));
|
||||
dir = dir.BeforeLast(wxT('/'));
|
||||
if (!filename.IsEmpty() && m_BaseDir == dir &&
|
||||
|
@ -119,6 +119,8 @@ wxNodeBase *wxHashTableBase::GetNode(long key, long value) const
|
||||
return node;
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxHashTableLong
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -334,6 +336,8 @@ bool wxStringHashTable::Delete(long key) const
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// old not type safe wxHashTable
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -1906,6 +1906,8 @@ void wxArrayString::Shrink()
|
||||
}
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
// return a wxString[] as required for some control ctors.
|
||||
wxString* wxArrayString::GetStringArray() const
|
||||
{
|
||||
@ -1921,6 +1923,8 @@ wxString* wxArrayString::GetStringArray() const
|
||||
return array;
|
||||
}
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
// searches the array for an item (forward or backwards)
|
||||
int wxArrayString::Index(const wxChar *sz, bool bCase, bool bFromEnd) const
|
||||
{
|
||||
@ -2051,7 +2055,7 @@ void wxArrayString::SetCount(size_t count)
|
||||
}
|
||||
|
||||
// removes item from array (by index)
|
||||
void wxArrayString::Remove(size_t nIndex, size_t nRemove)
|
||||
void wxArrayString::RemoveAt(size_t nIndex, size_t nRemove)
|
||||
{
|
||||
wxCHECK_RET( nIndex < m_nCount, wxT("bad index in wxArrayString::Remove") );
|
||||
wxCHECK_RET( nIndex + nRemove <= m_nCount,
|
||||
@ -2074,7 +2078,7 @@ void wxArrayString::Remove(const wxChar *sz)
|
||||
wxCHECK_RET( iIndex != wxNOT_FOUND,
|
||||
wxT("removing inexistent element in wxArrayString::Remove") );
|
||||
|
||||
Remove(iIndex);
|
||||
RemoveAt(iIndex);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -2142,18 +2146,22 @@ void wxArrayString::Sort(CompareFunction compareFunction)
|
||||
END_SORT();
|
||||
}
|
||||
|
||||
typedef int (wxC_CALLING_CONV * wxStringCompareFn)(const void *first, const void *second);
|
||||
|
||||
void wxArrayString::Sort(CompareFunction2 compareFunction)
|
||||
{
|
||||
qsort(m_pItems, m_nCount, sizeof(wxChar *), (wxStringCompareFn)compareFunction);
|
||||
}
|
||||
|
||||
#if WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
void wxArrayString::Sort(bool reverseOrder)
|
||||
{
|
||||
START_SORT();
|
||||
|
||||
wxASSERT( !gs_compareFunction ); // must have been reset to NULL
|
||||
gs_sortAscending = !reverseOrder;
|
||||
|
||||
DoSort();
|
||||
|
||||
END_SORT();
|
||||
Sort(reverseOrder ? wxStringSortDescending : wxStringSortAscending);
|
||||
}
|
||||
|
||||
#endif // WXWIN_COMPATIBILITY_2_4
|
||||
|
||||
void wxArrayString::DoSort()
|
||||
{
|
||||
wxCHECK_RET( !m_autoSort, wxT("can't use this method with sorted arrays") );
|
||||
@ -2177,3 +2185,12 @@ bool wxArrayString::operator==(const wxArrayString& a) const
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxStringSortAscending(wxString* s1, wxString* s2)
|
||||
{
|
||||
return wxStrcmp(s1->c_str(), s2->c_str());
|
||||
}
|
||||
|
||||
int wxStringSortDescending(wxString* s1, wxString* s2)
|
||||
{
|
||||
return -wxStrcmp(s1->c_str(), s2->c_str());
|
||||
}
|
||||
|
@ -9377,27 +9377,27 @@ void wxGrid::SetColSize( int col, int width )
|
||||
void wxGrid::SetColMinimalWidth( int col, int width )
|
||||
{
|
||||
if (width > GetColMinimalAcceptableWidth()) {
|
||||
m_colMinWidths.Put(col, width);
|
||||
m_colMinWidths[col] = width;
|
||||
}
|
||||
}
|
||||
|
||||
void wxGrid::SetRowMinimalHeight( int row, int width )
|
||||
{
|
||||
if (width > GetRowMinimalAcceptableHeight()) {
|
||||
m_rowMinHeights.Put(row, width);
|
||||
m_rowMinHeights[row] = width;
|
||||
}
|
||||
}
|
||||
|
||||
int wxGrid::GetColMinimalWidth(int col) const
|
||||
{
|
||||
long value = m_colMinWidths.Get(col);
|
||||
return value != wxNOT_FOUND ? (int)value : m_minAcceptableColWidth;
|
||||
wxLongToLongHashMap::const_iterator it = m_colMinWidths.find(col);
|
||||
return it != m_colMinWidths.end() ? (int)it->second : m_minAcceptableColWidth;
|
||||
}
|
||||
|
||||
int wxGrid::GetRowMinimalHeight(int row) const
|
||||
{
|
||||
long value = m_rowMinHeights.Get(row);
|
||||
return value != wxNOT_FOUND ? (int)value : m_minAcceptableRowHeight;
|
||||
wxLongToLongHashMap::const_iterator it = m_rowMinHeights.find(row);
|
||||
return it != m_rowMinHeights.end() ? (int)it->second : m_minAcceptableRowHeight;
|
||||
}
|
||||
|
||||
void wxGrid::SetColMinimalAcceptableWidth( int width )
|
||||
|
@ -657,7 +657,7 @@ void wxListBox::Delete( int n )
|
||||
}
|
||||
|
||||
if ( m_strings )
|
||||
m_strings->Remove(n);
|
||||
m_strings->RemoveAt(n);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -657,7 +657,7 @@ void wxListBox::Delete( int n )
|
||||
}
|
||||
|
||||
if ( m_strings )
|
||||
m_strings->Remove(n);
|
||||
m_strings->RemoveAt(n);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -496,7 +496,11 @@ wxHtmlHelpFrame::~wxHtmlHelpFrame()
|
||||
delete m_Data;
|
||||
if (m_NormalFonts) delete m_NormalFonts;
|
||||
if (m_FixedFonts) delete m_FixedFonts;
|
||||
if (m_PagesHash) delete m_PagesHash;
|
||||
if (m_PagesHash)
|
||||
{
|
||||
WX_CLEAR_HASH_TABLE(*m_PagesHash);
|
||||
delete m_PagesHash;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -719,9 +723,12 @@ void wxHtmlHelpFrame::CreateContents()
|
||||
|
||||
m_ContentsBox->Clear();
|
||||
|
||||
if (m_PagesHash) delete m_PagesHash;
|
||||
if (m_PagesHash)
|
||||
{
|
||||
WX_CLEAR_HASH_TABLE(*m_PagesHash);
|
||||
delete m_PagesHash;
|
||||
}
|
||||
m_PagesHash = new wxHashTable(wxKEY_STRING, 2 * m_Data->GetContentsCnt());
|
||||
m_PagesHash->DeleteContents(TRUE);
|
||||
|
||||
int cnt = m_Data->GetContentsCnt();
|
||||
int i;
|
||||
@ -1310,8 +1317,8 @@ void wxHtmlHelpFrame::OnToolbar(wxCommandEvent& event)
|
||||
pos = m_BookmarksNames.Index(item);
|
||||
if (pos != wxNOT_FOUND)
|
||||
{
|
||||
m_BookmarksNames.Remove(pos);
|
||||
m_BookmarksPages.Remove(pos);
|
||||
m_BookmarksNames.RemoveAt(pos);
|
||||
m_BookmarksPages.RemoveAt(pos);
|
||||
m_Bookmarks->Delete(m_Bookmarks->GetSelection());
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ wxMenu *wxMenuBar::Remove(size_t pos)
|
||||
|
||||
menu->SetMenuBar(NULL);
|
||||
|
||||
m_titles.Remove(pos);
|
||||
m_titles.RemoveAt(pos);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ wxMenu *wxMenuBar::Remove(size_t pos)
|
||||
Refresh();
|
||||
}
|
||||
|
||||
m_titles.Remove(pos);
|
||||
m_titles.RemoveAt(pos);
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
@ -354,7 +354,7 @@ static bool BuildRemoteList(wxArrayString& list, NETRESOURCE* pResSrc,
|
||||
{
|
||||
// Found the element. Remove it or mark it mounted.
|
||||
if (flagsUnset & wxFS_VOL_MOUNTED)
|
||||
list.Remove(iList);
|
||||
list.RemoveAt(iList);
|
||||
else
|
||||
s_fileInfo[list[iList]].m_flags |= wxFS_VOL_MOUNTED;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user