use wxWindowIDRef to transparently implement auto-generated ids ref-counting (slightly modified patch 1835458)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@51035 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2008-01-06 14:38:44 +00:00
parent 7d287e713f
commit cf2810aa39
34 changed files with 748 additions and 189 deletions

View File

@@ -129,6 +129,7 @@ void wxRadioBox::Init()
{
m_selectedButton = wxNOT_FOUND;
m_radioButtons = NULL;
m_radioButtonIds = NULL;
m_radioWidth = NULL;
m_radioHeight = NULL;
}
@@ -156,6 +157,7 @@ bool wxRadioBox::Create(wxWindow *parent,
#endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
m_radioButtons = new wxSubwindows(n);
m_radioButtonIds = new wxWindowIDRef[n + 1];
m_radioWidth = new int[n];
m_radioHeight = new int[n];
@@ -167,14 +169,14 @@ bool wxRadioBox::Create(wxWindow *parent,
if ( i == 0 )
styleBtn |= WS_GROUP;
long newId = NewControlId();
m_radioButtonIds[i] = NewControlId();
HWND hwndBtn = ::CreateWindow(_T("BUTTON"),
choices[i].wx_str(),
styleBtn,
0, 0, 0, 0, // will be set in SetSize()
GetHwndOf(parent),
(HMENU)newId,
(HMENU)(wxWindowID)m_radioButtonIds[i],
wxGetInstance(),
NULL);
@@ -189,15 +191,17 @@ bool wxRadioBox::Create(wxWindow *parent,
SubclassRadioButton((WXHWND)hwndBtn);
m_subControls.Add(newId);
m_subControls.Add(m_radioButtonIds[i]);
}
// Create a dummy radio control to end the group.
m_radioButtonIds[n] = NewControlId();
(void)::CreateWindow(_T("BUTTON"),
wxEmptyString,
WS_GROUP | BS_AUTORADIOBUTTON | WS_CHILD,
0, 0, 0, 0, GetHwndOf(parent),
(HMENU)NewControlId(), wxGetInstance(), NULL);
(HMENU)(wxWindowID)m_radioButtonIds[n], wxGetInstance(), NULL);
m_radioButtons->SetFont(GetFont());
@@ -237,6 +241,7 @@ wxRadioBox::~wxRadioBox()
m_isBeingDeleted = true;
delete m_radioButtons;
delete[] m_radioButtonIds;
delete[] m_radioWidth;
delete[] m_radioHeight;
}