- // We may be faking the client origin. So a window that's really at (0, 30)
- // may appear (to wxWin apps) to be at (0, 0).
- if (GetParent())
- {
- wxPoint pt(GetParent()->GetClientAreaOrigin());
- point.x -= pt.x;
- point.y -= pt.y;
- }
-
- *x = point.x;
- *y = point.y;
-}
-
-void wxRadioBox::SetFocus()
-{
- if (m_noItems > 0)
- {
- if (m_selectedButton == -1)
- ::SetFocus((HWND) m_radioButtons[0]);
- else
- ::SetFocus((HWND) m_radioButtons[m_selectedButton]);
- }
-
-}
-
-bool wxRadioBox::Show(bool show)
-{
- if ( !wxControl::Show(show) )
- return FALSE;
-
- int nCmdShow = show ? SW_SHOW : SW_HIDE;
- for ( int i = 0; i < m_noItems; i++ )
- {
- ::ShowWindow((HWND)m_radioButtons[i], nCmdShow);
- }
-
- return TRUE;
-}
-
-// Enable a specific button
-void wxRadioBox::Enable(int item, bool enable)
-{
- wxCHECK_RET( item >= 0 && item < m_noItems,
- wxT("invalid item in wxRadioBox::Enable()") );
-
- ::EnableWindow((HWND) m_radioButtons[item], enable);
-}
-
-// 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);
- 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)
-{
- // No GWL_USERDATA in Win16, so omit this subclassing.
-#ifdef __WIN32__
- HWND hwndBtn = (HWND)hWndBtn;
-
- if ( !s_wndprocRadioBtn )
- s_wndprocRadioBtn = (WXFARPROC)::GetWindowLong(hwndBtn, GWL_WNDPROC);
-
- ::SetWindowLong(hwndBtn, GWL_WNDPROC, (long)wxRadioBtnWndProc);
- ::SetWindowLong(hwndBtn, GWL_USERDATA, (long)this);
-#endif // __WIN32__
-}
-
-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 */);