1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/radiobox.cpp
3 // Purpose: wxRadioBox implementation
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
29 #include "wx/radiobox.h"
32 #include "wx/hashmap.h"
33 #include "wx/bitmap.h"
35 #include "wx/settings.h"
39 #include "wx/msw/subwin.h"
42 #include "wx/tooltip.h"
43 #endif // wxUSE_TOOLTIPS
45 // TODO: wxCONSTRUCTOR
46 #if 0 // wxUSE_EXTENDED_RTTI
47 WX_DEFINE_FLAGS( wxRadioBoxStyle
)
49 wxBEGIN_FLAGS( wxRadioBoxStyle
)
50 // new style border flags, we put them first to
51 // use them for streaming out
52 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
53 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
54 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
55 wxFLAGS_MEMBER(wxBORDER_RAISED
)
56 wxFLAGS_MEMBER(wxBORDER_STATIC
)
57 wxFLAGS_MEMBER(wxBORDER_NONE
)
59 // old style border flags
60 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
61 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
62 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
63 wxFLAGS_MEMBER(wxRAISED_BORDER
)
64 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
65 wxFLAGS_MEMBER(wxBORDER
)
67 // standard window styles
68 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
69 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
70 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
71 wxFLAGS_MEMBER(wxWANTS_CHARS
)
72 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
73 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
74 wxFLAGS_MEMBER(wxVSCROLL
)
75 wxFLAGS_MEMBER(wxHSCROLL
)
77 wxFLAGS_MEMBER(wxRA_SPECIFY_COLS
)
78 wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS
)
79 wxEND_FLAGS( wxRadioBoxStyle
)
81 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox
, wxControl
,"wx/radiobox.h")
83 wxBEGIN_PROPERTIES_TABLE(wxRadioBox
)
84 wxEVENT_PROPERTY( Select
, wxEVT_RADIOBOX
, wxCommandEvent
)
85 wxPROPERTY_FLAGS( WindowStyle
, wxRadioBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
86 wxEND_PROPERTIES_TABLE()
89 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox
, wxControl
)
100 // ---------------------------------------------------------------------------
102 // ---------------------------------------------------------------------------
104 // wnd proc for radio buttons
105 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hWnd
,
110 // ---------------------------------------------------------------------------
112 // ---------------------------------------------------------------------------
117 // the pointer to standard radio button wnd proc
118 WXFARPROC s_wndprocRadioBtn
= (WXFARPROC
)NULL
;
120 // Hash allowing to find wxRadioBox containing the given radio button by its
121 // HWND. This is used by (subclassed) radio button window proc to find the
122 // radio box it belongs to.
123 WX_DECLARE_HASH_MAP(HWND
, wxRadioBox
*,
124 wxPointerHash
, wxPointerEqual
,
127 RadioBoxFromButton gs_boxFromButton
;
129 } // anonymous namespace
131 // ===========================================================================
133 // ===========================================================================
136 wxRadioBox
* wxRadioBox::GetFromRadioButtonHWND(WXHWND hwnd
)
138 const RadioBoxFromButton::const_iterator it
= gs_boxFromButton
.find(hwnd
);
139 return it
== gs_boxFromButton
.end() ? NULL
: it
->second
;
142 // ---------------------------------------------------------------------------
143 // wxRadioBox creation
144 // ---------------------------------------------------------------------------
147 void wxRadioBox::Init()
149 m_selectedButton
= wxNOT_FOUND
;
150 m_radioButtons
= NULL
;
153 m_radioHeight
= NULL
;
156 bool wxRadioBox::Create(wxWindow
*parent
,
158 const wxString
& title
,
162 const wxString choices
[],
165 const wxValidator
& val
,
166 const wxString
& name
)
168 // common initialization
169 if ( !wxStaticBox::Create(parent
, id
, title
, pos
, size
, style
, name
) )
172 // the code elsewhere in this file supposes that either wxRA_SPECIFY_COLS
173 // or wxRA_SPECIFY_ROWS is set, ensure that this is indeed the case
174 if ( !(style
& (wxRA_SPECIFY_ROWS
| wxRA_SPECIFY_COLS
)) )
175 style
|= wxRA_SPECIFY_COLS
;
181 #endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
183 // We need an extra one to keep track of the 'dummy' item we
184 // create to end the radio group, so it will be destroyed and
185 // it's id will be released. But we want it separate from the
186 // other buttons since the wxSubwindows will operate on it as
187 // well and we just want to ignore it until destroying it.
188 // For instance, we don't want the bounding box of the radio
189 // buttons to include the dummy button
190 m_radioButtons
= new wxSubwindows(n
);
192 m_radioWidth
= new int[n
];
193 m_radioHeight
= new int[n
];
195 for ( int i
= 0; i
< n
; i
++ )
198 m_radioHeight
[i
] = wxDefaultCoord
;
199 long styleBtn
= BS_AUTORADIOBUTTON
| WS_TABSTOP
| WS_CHILD
| WS_VISIBLE
;
201 styleBtn
|= WS_GROUP
;
203 wxWindowIDRef subid
= NewControlId();
205 HWND hwndBtn
= ::CreateWindow(wxT("BUTTON"),
208 0, 0, 0, 0, // will be set in SetSize()
210 (HMENU
)wxUIntToPtr(subid
.GetValue()),
216 wxLogLastError(wxT("CreateWindow(radio btn)"));
221 // Keep track of the subwindow
222 m_radioButtons
->Set(i
, hwndBtn
, subid
);
224 SubclassRadioButton((WXHWND
)hwndBtn
);
226 // Also, make it a subcontrol of this control
227 m_subControls
.Add(subid
);
230 // Create a dummy radio control to end the group.
231 m_dummyId
= NewControlId();
233 m_dummyHwnd
= (WXHWND
)::CreateWindow(wxT("BUTTON"),
235 WS_GROUP
| BS_AUTORADIOBUTTON
| WS_CHILD
,
236 0, 0, 0, 0, GetHwndOf(parent
),
237 (HMENU
)wxUIntToPtr(m_dummyId
.GetValue()),
238 wxGetInstance(), NULL
);
241 m_radioButtons
->SetFont(GetFont());
244 // Set the z-order correctly
245 SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
248 SetMajorDim(majorDim
== 0 ? n
: majorDim
, style
);
250 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
252 // Now that we have items determine what is the best size and set it.
253 SetInitialSize(size
);
255 // And update all the buttons positions to match it.
256 const wxSize actualSize
= GetSize();
257 PositionAllButtons(pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
259 // The base wxStaticBox class never accepts focus, but we do because giving
260 // focus to a wxRadioBox actually gives it to one of its buttons, which are
261 // not visible at wx level and hence are not taken into account by the
262 // logic in wxControlContainer code.
263 m_container
.EnableSelfFocus();
268 bool wxRadioBox::Create(wxWindow
*parent
,
270 const wxString
& title
,
273 const wxArrayString
& choices
,
276 const wxValidator
& val
,
277 const wxString
& name
)
279 wxCArrayString
chs(choices
);
280 return Create(parent
, id
, title
, pos
, size
, chs
.GetCount(),
281 chs
.GetStrings(), majorDim
, style
, val
, name
);
284 wxRadioBox::~wxRadioBox()
288 // Unsubclass all the radio buttons and remove their soon-to-be-invalid
289 // HWNDs from the global map. Notice that we need to unsubclass because
290 // otherwise we'd need the entries in gs_boxFromButton for the buttons
291 // being deleted to handle the messages generated during their destruction.
292 for ( size_t item
= 0; item
< m_radioButtons
->GetCount(); item
++ )
294 HWND hwnd
= m_radioButtons
->Get(item
);
296 wxSetWindowProc(hwnd
, reinterpret_cast<WNDPROC
>(s_wndprocRadioBtn
));
297 gs_boxFromButton
.erase(hwnd
);
300 delete m_radioButtons
;
303 DestroyWindow((HWND
)m_dummyHwnd
);
305 delete[] m_radioWidth
;
306 delete[] m_radioHeight
;
309 // NB: if this code is changed, wxGetWindowForHWND() which relies on having the
310 // radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
311 void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn
)
313 HWND hwndBtn
= (HWND
)hWndBtn
;
315 if ( !s_wndprocRadioBtn
)
316 s_wndprocRadioBtn
= (WXFARPROC
)wxGetWindowProc(hwndBtn
);
318 wxSetWindowProc(hwndBtn
, wxRadioBtnWndProc
);
320 gs_boxFromButton
[hwndBtn
] = this;
323 // ----------------------------------------------------------------------------
325 // ----------------------------------------------------------------------------
327 bool wxRadioBox::MSWCommand(WXUINT cmd
, WXWORD id_
)
329 const int id
= (signed short)id_
;
331 if ( cmd
== BN_CLICKED
)
336 int selectedButton
= wxNOT_FOUND
;
338 const unsigned int count
= GetCount();
339 for ( unsigned int i
= 0; i
< count
; i
++ )
341 const HWND hwndBtn
= (*m_radioButtons
)[i
];
342 if ( id
== wxGetWindowId(hwndBtn
) )
344 // we can get BN_CLICKED for a button which just became focused
345 // but it may not be checked, in which case we shouldn't
346 // generate a radiobox selection changed event for it
347 if ( ::SendMessage(hwndBtn
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
354 if ( selectedButton
== wxNOT_FOUND
)
356 // just ignore it - due to a hack with WM_NCHITTEST handling in our
357 // wnd proc, we can receive dummy click messages when we click near
358 // the radiobox edge (this is ugly but Julian wouldn't let me get
363 if ( selectedButton
!= m_selectedButton
)
365 m_selectedButton
= selectedButton
;
367 SendNotificationEvent();
369 //else: don't generate events when the selection doesn't change
377 void wxRadioBox::Command(wxCommandEvent
& event
)
379 SetSelection (event
.GetInt());
381 ProcessCommand(event
);
384 void wxRadioBox::SendNotificationEvent()
386 wxCommandEvent
event(wxEVT_RADIOBOX
, m_windowId
);
387 event
.SetInt( m_selectedButton
);
388 event
.SetString(GetString(m_selectedButton
));
389 event
.SetEventObject( this );
390 ProcessCommand(event
);
393 // ----------------------------------------------------------------------------
395 // ----------------------------------------------------------------------------
397 unsigned int wxRadioBox::GetCount() const
399 return m_radioButtons
? m_radioButtons
->GetCount() : 0u;
402 void wxRadioBox::SetString(unsigned int item
, const wxString
& label
)
404 wxCHECK_RET( IsValid(item
), wxT("invalid radiobox index") );
407 m_radioHeight
[item
] = wxDefaultCoord
;
409 ::SetWindowText((*m_radioButtons
)[item
], label
.c_str());
411 InvalidateBestSize();
414 void wxRadioBox::SetSelection(int N
)
416 wxCHECK_RET( IsValid(N
), wxT("invalid radiobox index") );
418 // unselect the old button
419 if ( m_selectedButton
!= wxNOT_FOUND
)
420 ::SendMessage((*m_radioButtons
)[m_selectedButton
], BM_SETCHECK
, 0, 0L);
422 // and select the new one
423 ::SendMessage((*m_radioButtons
)[N
], BM_SETCHECK
, 1, 0L);
425 m_selectedButton
= N
;
428 // Find string for position
429 wxString
wxRadioBox::GetString(unsigned int item
) const
431 wxCHECK_MSG( IsValid(item
), wxEmptyString
,
432 wxT("invalid radiobox index") );
434 return wxGetWindowText((*m_radioButtons
)[item
]);
437 void wxRadioBox::SetFocus()
439 if ( GetCount() > 0 )
441 ::SetFocus((*m_radioButtons
)[m_selectedButton
== wxNOT_FOUND
443 : m_selectedButton
]);
447 // Enable a specific button
448 bool wxRadioBox::Enable(unsigned int item
, bool enable
)
450 wxCHECK_MSG( IsValid(item
), false,
451 wxT("invalid item in wxRadioBox::Enable()") );
453 BOOL ret
= MSWEnableHWND((*m_radioButtons
)[item
], enable
);
455 return (ret
== 0) != enable
;
458 bool wxRadioBox::IsItemEnabled(unsigned int item
) const
460 wxCHECK_MSG( IsValid(item
), false,
461 wxT("invalid item in wxRadioBox::IsItemEnabled()") );
463 return ::IsWindowEnabled((*m_radioButtons
)[item
]) != 0;
466 // Show a specific button
467 bool wxRadioBox::Show(unsigned int item
, bool show
)
469 wxCHECK_MSG( IsValid(item
), false,
470 wxT("invalid item in wxRadioBox::Show()") );
472 BOOL ret
= ::ShowWindow((*m_radioButtons
)[item
], show
? SW_SHOW
: SW_HIDE
);
474 bool changed
= (ret
!= 0) != show
;
477 InvalidateBestSize();
483 bool wxRadioBox::IsItemShown(unsigned int item
) const
485 wxCHECK_MSG( IsValid(item
), false,
486 wxT("invalid item in wxRadioBox::IsItemShown()") );
488 // don't use IsWindowVisible() here because it would return false if the
489 // radiobox itself is hidden while we want to only return false if this
490 // button specifically is hidden
491 return (::GetWindowLong((*m_radioButtons
)[item
],
492 GWL_STYLE
) & WS_VISIBLE
) != 0;
497 bool wxRadioBox::HasToolTips() const
499 return wxStaticBox::HasToolTips() || wxRadioBoxBase::HasItemToolTips();
502 void wxRadioBox::DoSetItemToolTip(unsigned int item
, wxToolTip
*tooltip
)
504 // we have already checked for the item to be valid in wxRadioBoxBase
505 const HWND hwndRbtn
= (*m_radioButtons
)[item
];
506 if ( tooltip
!= NULL
)
507 tooltip
->AddOtherWindow(hwndRbtn
);
508 else // unset the tooltip
509 wxToolTip::Remove(hwndRbtn
, 0, wxRect(0,0,0,0));
510 // the second parameter can be zero since it's ignored by Remove()
511 // as we pass a rect for which wxRect::IsEmpty()==true...
514 #endif // wxUSE_TOOLTIPS
516 bool wxRadioBox::Reparent(wxWindowBase
*newParent
)
518 if ( !wxStaticBox::Reparent(newParent
) )
523 HWND hwndParent
= GetHwndOf(GetParent());
524 for ( size_t item
= 0; item
< m_radioButtons
->GetCount(); item
++ )
526 ::SetParent((*m_radioButtons
)[item
], hwndParent
);
529 // put static box under the buttons in the Z-order
530 SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
535 WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox
, wxStaticBox
, m_radioButtons
)
537 // ----------------------------------------------------------------------------
539 // ----------------------------------------------------------------------------
541 wxSize
wxRadioBox::GetMaxButtonSize() const
543 // calculate the max button size
546 const unsigned int count
= GetCount();
547 for ( unsigned int i
= 0 ; i
< count
; i
++ )
550 if ( m_radioWidth
[i
] < 0 )
552 GetTextExtent(wxGetWindowText((*m_radioButtons
)[i
]), &width
, &height
);
554 // adjust the size to take into account the radio box itself
555 // FIXME this is totally bogus!
562 width
= m_radioWidth
[i
];
563 height
= m_radioHeight
[i
];
566 if ( widthMax
< width
)
568 if ( heightMax
< height
)
572 return wxSize(widthMax
, heightMax
);
575 wxSize
wxRadioBox::GetTotalButtonSize(const wxSize
& sizeBtn
) const
577 // the radiobox should be big enough for its buttons
579 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
581 int extraHeight
= cy1
;
583 int height
= GetRowCount() * sizeBtn
.y
+ cy1
/2 + extraHeight
;
584 int width
= GetColumnCount() * (sizeBtn
.x
+ cx1
) + cx1
;
586 // Add extra space under the label, if it exists.
587 if (!wxControl::GetLabel().empty())
590 // and also wide enough for its label
592 GetTextExtent(GetLabelText(), &widthLabel
, NULL
);
593 widthLabel
+= RADIO_SIZE
; // FIXME this is bogus too
594 if ( widthLabel
> width
)
597 return wxSize(width
, height
);
600 wxSize
wxRadioBox::DoGetBestSize() const
602 if ( !m_radioButtons
)
604 // if we're not fully initialized yet, we can't meaningfully compute
605 // our best size, we'll do it later
609 wxSize best
= GetTotalButtonSize(GetMaxButtonSize());
614 void wxRadioBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
616 if ( (width
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_WIDTH
)) ||
617 (height
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_HEIGHT
)) )
619 // Attempt to have a look coherent with other platforms: We compute the
620 // biggest toggle dim, then we align all items according this value.
621 const wxSize totSize
= GetTotalButtonSize(GetMaxButtonSize());
623 // only change our width/height if asked for
624 if ( width
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_WIDTH
) )
627 if ( height
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_HEIGHT
) )
631 wxStaticBox::DoSetSize(x
, y
, width
, height
);
634 void wxRadioBox::DoMoveWindow(int x
, int y
, int width
, int height
)
636 wxStaticBox::DoMoveWindow(x
, y
, width
, height
);
638 PositionAllButtons(x
, y
, width
, height
);
642 wxRadioBox::PositionAllButtons(int x
, int y
, int width
, int WXUNUSED(height
))
644 wxSize maxSize
= GetMaxButtonSize();
645 int maxWidth
= maxSize
.x
,
646 maxHeight
= maxSize
.y
;
648 // Now position all the buttons: the current button will be put at
649 // wxPoint(x_offset, y_offset) and the new row/column will start at
650 // startX/startY. The size of all buttons will be the same wxSize(maxWidth,
651 // maxHeight) except for the buttons in the last column which should extend
652 // to the right border of radiobox and thus can be wider than this.
654 // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in
655 // left to right order and GetMajorDim() is the number of columns while
656 // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and
657 // GetMajorDim() is the number of rows.
660 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
662 int x_offset
= x
+ cx1
;
663 int y_offset
= y
+ cy1
;
665 // Add extra space under the label, if it exists.
666 if (!wxControl::GetLabel().empty())
669 int startX
= x_offset
;
670 int startY
= y_offset
;
672 const unsigned int count
= GetCount();
673 for (unsigned int i
= 0; i
< count
; i
++)
675 // the last button in the row may be wider than the other ones as the
676 // radiobox may be wider than the sum of the button widths (as it
677 // happens, for example, when the radiobox label is very long)
679 if ( m_windowStyle
& wxRA_SPECIFY_COLS
)
681 // item is the last in its row if it is a multiple of the number of
682 // columns or if it is just the last item
683 unsigned int n
= i
+ 1;
684 isLastInTheRow
= ((n
% GetMajorDim()) == 0) || (n
== count
);
686 else // wxRA_SPECIFY_ROWS
688 // item is the last in the row if it is in the last columns
689 isLastInTheRow
= i
>= (count
/GetMajorDim())*GetMajorDim();
692 // is this the start of new row/column?
693 if ( i
&& (i
% GetMajorDim() == 0) )
695 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
697 // start of new column
699 x_offset
+= maxWidth
+ cx1
;
701 else // start of new row
704 y_offset
+= maxHeight
;
705 if (m_radioWidth
[0]>0)
711 if ( isLastInTheRow
)
713 // make the button go to the end of radio box
714 widthBtn
= startX
+ width
- x_offset
- 2*cx1
;
715 if ( widthBtn
< maxWidth
)
720 // normal button, always of the same size
724 // make all buttons of the same, maximal size - like this they cover
725 // the radiobox entirely and the radiobox tooltips are always shown
726 // (otherwise they are not when the mouse pointer is in the radiobox
727 // part not belonging to any radiobutton)
728 DoMoveSibling((*m_radioButtons
)[i
], x_offset
, y_offset
, widthBtn
, maxHeight
);
730 // where do we put the next button?
731 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
734 y_offset
+= maxHeight
;
735 if (m_radioWidth
[0]>0)
740 // to the right of this one
741 x_offset
+= widthBtn
+ cx1
;
746 int wxRadioBox::GetItemFromPoint(const wxPoint
& pt
) const
748 const unsigned int count
= GetCount();
749 for ( unsigned int i
= 0; i
< count
; i
++ )
751 RECT rect
= wxGetWindowRect((*m_radioButtons
)[i
]);
753 if ( rect
.left
<= pt
.x
&& pt
.x
< rect
.right
&&
754 rect
.top
<= pt
.y
&& pt
.y
< rect
.bottom
)
763 // ----------------------------------------------------------------------------
765 // ----------------------------------------------------------------------------
769 WXHRGN
wxRadioBox::MSWGetRegionWithoutChildren()
772 ::GetWindowRect(GetHwnd(), &rc
);
773 HRGN hrgn
= ::CreateRectRgn(rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
775 const unsigned int count
= GetCount();
776 for ( unsigned int i
= 0; i
< count
; ++i
)
778 // don't clip out hidden children
779 if ( !IsItemShown(i
) )
782 ::GetWindowRect((*m_radioButtons
)[i
], &rc
);
783 AutoHRGN
hrgnchild(::CreateRectRgnIndirect(&rc
));
784 ::CombineRgn(hrgn
, hrgn
, hrgnchild
, RGN_DIFF
);
790 #endif // __WXWINCE__
792 // ---------------------------------------------------------------------------
793 // window proc for radio buttons
794 // ---------------------------------------------------------------------------
796 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hwnd
,
802 wxRadioBox
* const radiobox
= wxRadioBox::GetFromRadioButtonHWND(hwnd
);
803 wxCHECK_MSG( radiobox
, 0, wxT("Should have the associated radio box") );
808 // we must tell IsDialogMessage()/our kbd processing code that we
809 // want to process arrows ourselves because neither of them is
810 // smart enough to handle arrows properly for us
812 long lDlgCode
= ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
,
813 message
, wParam
, lParam
);
815 return lDlgCode
| DLGC_WANTARROWS
;
820 bool processed
= true;
844 // just to suppress the compiler warning
850 int selOld
= radiobox
->GetSelection();
851 int selNew
= radiobox
->GetNextItem
855 radiobox
->GetWindowStyle()
858 if ( selNew
!= selOld
)
860 radiobox
->SetSelection(selNew
);
861 radiobox
->SetFocus();
863 // emulate the button click
864 radiobox
->SendNotificationEvent();
875 // if we don't do this, no focus events are generated for the
876 // radiobox and, besides, we need to notify the parent about
877 // the focus change, otherwise the focus handling logic in
878 // wxControlContainer doesn't work
879 if ( message
== WM_SETFOCUS
)
880 radiobox
->HandleSetFocus((WXHWND
)wParam
);
882 radiobox
->HandleKillFocus((WXHWND
)wParam
);
889 bool processed
= false;
891 wxEvtHandler
* const handler
= radiobox
->GetEventHandler();
893 HELPINFO
* info
= (HELPINFO
*) lParam
;
894 if ( info
->iContextType
== HELPINFO_WINDOW
)
896 for ( wxWindow
* subjectOfHelp
= radiobox
;
898 subjectOfHelp
= subjectOfHelp
->GetParent() )
900 wxHelpEvent
helpEvent(wxEVT_HELP
,
901 subjectOfHelp
->GetId(),
902 wxPoint(info
->MousePos
.x
,
904 helpEvent
.SetEventObject(radiobox
);
905 if ( handler
->ProcessEvent(helpEvent
) )
912 else if (info
->iContextType
== HELPINFO_MENUITEM
)
914 wxHelpEvent
helpEvent(wxEVT_HELP
, info
->iCtrlId
);
915 helpEvent
.SetEventObject(radiobox
);
916 processed
= handler
->ProcessEvent(helpEvent
);
923 #endif // !__WXWINCE__
926 return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
, message
, wParam
, lParam
);
929 #endif // wxUSE_RADIOBOX