store ids of sub-items directly in wxSubwindows instead of using a parallel data structure (patch 1865577)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51065 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-01-07 01:54:33 +00:00
parent fb25206791
commit 52ca4ec419
5 changed files with 59 additions and 28 deletions

View File

@@ -32,6 +32,7 @@ public:
m_count = n;
m_hwnds = (HWND *)calloc(n, sizeof(HWND));
m_ids = new wxWindowIDRef[n];
}
// non-virtual dtor, this class is not supposed to be used polymorphically
@@ -43,6 +44,7 @@ public:
}
free(m_hwnds);
delete [] m_ids;
}
// get the number of subwindows
@@ -56,12 +58,21 @@ public:
return m_hwnds[n];
}
HWND& operator[](size_t n) { return Get(n); }
HWND operator[](size_t n) const
{
return wx_const_cast(wxSubwindows *, this)->Get(n);
}
// initialize the given window: id will be stored in wxWindowIDRef ensuring
// that it is not reused while this object exists
void Set(size_t n, HWND hwnd, wxWindowID id)
{
wxASSERT_MSG( n < m_count, _T("subwindow index out of range") );
m_hwnds[n] = hwnd;
m_ids[n] = id;
}
// check if we have this window
bool HasWindow(HWND hwnd)
{
@@ -140,6 +151,9 @@ private:
// the HWNDs we contain
HWND *m_hwnds;
// the IDs of the windows
wxWindowIDRef *m_ids;
DECLARE_NO_COPY_CLASS(wxSubwindows)
};