-// Enable all controls
-bool wxRadioBox::Enable(bool enable)
-{
- if ( !wxControl::Enable(enable) )
- return false;
-
- for (int i = 0; i < m_noItems; i++)
- ::EnableWindow((HWND) m_radioButtons[i], enable);
-
- return true;
-}
-
-// Show a specific button
-void wxRadioBox::Show(int item, bool show)
-{
- wxCHECK_RET( item >= 0 && item < m_noItems,
- wxT("invalid item in wxRadioBox::Show()") );
-
- ::ShowWindow((HWND)m_radioButtons[item], show ? SW_SHOW : SW_HIDE);
-}
-
-bool wxRadioBox::ContainsHWND(WXHWND hWnd) const
-{
- size_t count = GetCount();
- for ( size_t i = 0; i < count; i++ )
- {
- if ( GetRadioButtons()[i] == hWnd )
- return true;
- }
-
- return false;
-}
-
-void wxRadioBox::Command(wxCommandEvent & event)
-{
- SetSelection (event.m_commandInt);
- SetFocus();
- ProcessCommand (event);
-}
-
-// NB: if this code is changed, wxGetWindowForHWND() which relies on having the
-// radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
-void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn)
-{
- HWND hwndBtn = (HWND)hWndBtn;
-
- if ( !s_wndprocRadioBtn )
- s_wndprocRadioBtn = (WXFARPROC)wxGetWindowProc(hwndBtn);
-
- wxSetWindowProc(hwndBtn, wxRadioBtnWndProc);
- wxSetWindowUserData(hwndBtn, this);
-}
-
-void wxRadioBox::SendNotificationEvent()
-{
- wxCommandEvent event(wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId);
- event.SetInt( m_selectedButton );
- event.SetString( GetString(m_selectedButton) );
- event.SetEventObject( this );
- ProcessCommand(event);
-}
-
-bool wxRadioBox::SetFont(const wxFont& font)
-{
- if ( !wxControl::SetFont(font) )
- {
- // nothing to do
- return false;
- }
-
- // also set the font of our radio buttons
- WXHFONT hfont = wxFont(font).GetResourceHandle();
- for ( int n = 0; n < m_noItems; n++ )
- {
- HWND hwndBtn = (HWND)m_radioButtons[n];
- ::SendMessage(hwndBtn, WM_SETFONT, (WPARAM)hfont, 0L);
-
- // otherwise the buttons are not redrawn correctly
- ::InvalidateRect(hwndBtn, NULL, FALSE /* don't erase bg */);
- }
-
- return true;
-}
-
-// ----------------------------------------------------------------------------
-// our window proc
-// ----------------------------------------------------------------------------
-
-WXLRESULT wxRadioBox::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam)
-{
-#if RADIOBTN_PARENT_IS_RADIOBOX
- switch ( nMsg )
- {
- // handle this message to set correct colours for our buttons here
- case WM_CTLCOLORSTATIC:
- {
- WXHDC hdc;
- WXHWND hwnd;
- UnpackCtlColor(wParam, lParam, &hdc, &hwnd);
-
- WXHBRUSH hbr = MSWControlColor((WXHDC)hdc);
- if ( hbr )
- return (WXLRESULT)hbr;
- //else: fall through to default window proc
- }
- }
-#endif // RADIOBTN_PARENT_IS_RADIOBOX
-
- return wxControl::MSWWindowProc(nMsg, wParam, lParam);
-}