1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/radiobox.cpp
3 // Purpose: wxRadioBox implementation
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
28 #include "wx/radiobox.h"
31 #include "wx/hashmap.h"
32 #include "wx/bitmap.h"
34 #include "wx/settings.h"
38 #include "wx/msw/subwin.h"
41 #include "wx/tooltip.h"
42 #endif // wxUSE_TOOLTIPS
44 // TODO: wxCONSTRUCTOR
45 #if 0 // wxUSE_EXTENDED_RTTI
46 WX_DEFINE_FLAGS( wxRadioBoxStyle
)
48 wxBEGIN_FLAGS( wxRadioBoxStyle
)
49 // new style border flags, we put them first to
50 // use them for streaming out
51 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
52 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
53 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
54 wxFLAGS_MEMBER(wxBORDER_RAISED
)
55 wxFLAGS_MEMBER(wxBORDER_STATIC
)
56 wxFLAGS_MEMBER(wxBORDER_NONE
)
58 // old style border flags
59 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
60 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
61 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
62 wxFLAGS_MEMBER(wxRAISED_BORDER
)
63 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
64 wxFLAGS_MEMBER(wxBORDER
)
66 // standard window styles
67 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
68 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
69 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
70 wxFLAGS_MEMBER(wxWANTS_CHARS
)
71 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
72 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
73 wxFLAGS_MEMBER(wxVSCROLL
)
74 wxFLAGS_MEMBER(wxHSCROLL
)
76 wxFLAGS_MEMBER(wxRA_SPECIFY_COLS
)
77 wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS
)
78 wxEND_FLAGS( wxRadioBoxStyle
)
80 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox
, wxControl
,"wx/radiobox.h")
82 wxBEGIN_PROPERTIES_TABLE(wxRadioBox
)
83 wxEVENT_PROPERTY( Select
, wxEVT_RADIOBOX
, wxCommandEvent
)
84 wxPROPERTY_FLAGS( WindowStyle
, wxRadioBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
85 wxEND_PROPERTIES_TABLE()
88 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox
, wxControl
)
99 // ---------------------------------------------------------------------------
101 // ---------------------------------------------------------------------------
103 // wnd proc for radio buttons
104 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hWnd
,
109 // ---------------------------------------------------------------------------
111 // ---------------------------------------------------------------------------
116 // the pointer to standard radio button wnd proc
117 WXFARPROC s_wndprocRadioBtn
= (WXFARPROC
)NULL
;
119 // Hash allowing to find wxRadioBox containing the given radio button by its
120 // HWND. This is used by (subclassed) radio button window proc to find the
121 // radio box it belongs to.
122 WX_DECLARE_HASH_MAP(HWND
, wxRadioBox
*,
123 wxPointerHash
, wxPointerEqual
,
126 RadioBoxFromButton gs_boxFromButton
;
128 } // anonymous namespace
130 // ===========================================================================
132 // ===========================================================================
135 wxRadioBox
* wxRadioBox::GetFromRadioButtonHWND(WXHWND hwnd
)
137 const RadioBoxFromButton::const_iterator it
= gs_boxFromButton
.find(hwnd
);
138 return it
== gs_boxFromButton
.end() ? NULL
: it
->second
;
141 // ---------------------------------------------------------------------------
142 // wxRadioBox creation
143 // ---------------------------------------------------------------------------
146 void wxRadioBox::Init()
148 m_selectedButton
= wxNOT_FOUND
;
149 m_radioButtons
= NULL
;
152 m_radioHeight
= NULL
;
155 bool wxRadioBox::Create(wxWindow
*parent
,
157 const wxString
& title
,
161 const wxString choices
[],
164 const wxValidator
& val
,
165 const wxString
& name
)
167 // common initialization
168 if ( !wxStaticBox::Create(parent
, id
, title
, pos
, size
, style
, name
) )
171 // the code elsewhere in this file supposes that either wxRA_SPECIFY_COLS
172 // or wxRA_SPECIFY_ROWS is set, ensure that this is indeed the case
173 if ( !(style
& (wxRA_SPECIFY_ROWS
| wxRA_SPECIFY_COLS
)) )
174 style
|= wxRA_SPECIFY_COLS
;
180 #endif // wxUSE_VALIDATORS/!wxUSE_VALIDATORS
182 // We need an extra one to keep track of the 'dummy' item we
183 // create to end the radio group, so it will be destroyed and
184 // it's id will be released. But we want it separate from the
185 // other buttons since the wxSubwindows will operate on it as
186 // well and we just want to ignore it until destroying it.
187 // For instance, we don't want the bounding box of the radio
188 // buttons to include the dummy button
189 m_radioButtons
= new wxSubwindows(n
);
191 m_radioWidth
= new int[n
];
192 m_radioHeight
= new int[n
];
194 for ( int i
= 0; i
< n
; i
++ )
197 m_radioHeight
[i
] = wxDefaultCoord
;
198 long styleBtn
= BS_AUTORADIOBUTTON
| WS_TABSTOP
| WS_CHILD
| WS_VISIBLE
;
200 styleBtn
|= WS_GROUP
;
202 wxWindowIDRef subid
= NewControlId();
204 HWND hwndBtn
= ::CreateWindow(wxT("BUTTON"),
207 0, 0, 0, 0, // will be set in SetSize()
209 (HMENU
)wxUIntToPtr(subid
.GetValue()),
215 wxLogLastError(wxT("CreateWindow(radio btn)"));
220 // Keep track of the subwindow
221 m_radioButtons
->Set(i
, hwndBtn
, subid
);
223 SubclassRadioButton((WXHWND
)hwndBtn
);
225 // Also, make it a subcontrol of this control
226 m_subControls
.Add(subid
);
229 // Create a dummy radio control to end the group.
230 m_dummyId
= NewControlId();
232 m_dummyHwnd
= (WXHWND
)::CreateWindow(wxT("BUTTON"),
234 WS_GROUP
| BS_AUTORADIOBUTTON
| WS_CHILD
,
235 0, 0, 0, 0, GetHwndOf(parent
),
236 (HMENU
)wxUIntToPtr(m_dummyId
.GetValue()),
237 wxGetInstance(), NULL
);
240 m_radioButtons
->SetFont(GetFont());
243 // Set the z-order correctly
244 SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
247 SetMajorDim(majorDim
== 0 ? n
: majorDim
, style
);
249 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
251 // Now that we have items determine what is the best size and set it.
252 SetInitialSize(size
);
254 // And update all the buttons positions to match it.
255 const wxSize actualSize
= GetSize();
256 PositionAllButtons(pos
.x
, pos
.y
, actualSize
.x
, actualSize
.y
);
258 // The base wxStaticBox class never accepts focus, but we do because giving
259 // focus to a wxRadioBox actually gives it to one of its buttons, which are
260 // not visible at wx level and hence are not taken into account by the
261 // logic in wxControlContainer code.
262 m_container
.EnableSelfFocus();
267 bool wxRadioBox::Create(wxWindow
*parent
,
269 const wxString
& title
,
272 const wxArrayString
& choices
,
275 const wxValidator
& val
,
276 const wxString
& name
)
278 wxCArrayString
chs(choices
);
279 return Create(parent
, id
, title
, pos
, size
, chs
.GetCount(),
280 chs
.GetStrings(), majorDim
, style
, val
, name
);
283 wxRadioBox::~wxRadioBox()
287 // Unsubclass all the radio buttons and remove their soon-to-be-invalid
288 // HWNDs from the global map. Notice that we need to unsubclass because
289 // otherwise we'd need the entries in gs_boxFromButton for the buttons
290 // being deleted to handle the messages generated during their destruction.
291 for ( size_t item
= 0; item
< m_radioButtons
->GetCount(); item
++ )
293 HWND hwnd
= m_radioButtons
->Get(item
);
295 wxSetWindowProc(hwnd
, reinterpret_cast<WNDPROC
>(s_wndprocRadioBtn
));
296 gs_boxFromButton
.erase(hwnd
);
299 delete m_radioButtons
;
302 DestroyWindow((HWND
)m_dummyHwnd
);
304 delete[] m_radioWidth
;
305 delete[] m_radioHeight
;
308 // NB: if this code is changed, wxGetWindowForHWND() which relies on having the
309 // radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
310 void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn
)
312 HWND hwndBtn
= (HWND
)hWndBtn
;
314 if ( !s_wndprocRadioBtn
)
315 s_wndprocRadioBtn
= (WXFARPROC
)wxGetWindowProc(hwndBtn
);
317 wxSetWindowProc(hwndBtn
, wxRadioBtnWndProc
);
319 gs_boxFromButton
[hwndBtn
] = this;
322 // ----------------------------------------------------------------------------
324 // ----------------------------------------------------------------------------
326 bool wxRadioBox::MSWCommand(WXUINT cmd
, WXWORD id_
)
328 const int id
= (signed short)id_
;
330 if ( cmd
== BN_CLICKED
)
335 int selectedButton
= wxNOT_FOUND
;
337 const unsigned int count
= GetCount();
338 for ( unsigned int i
= 0; i
< count
; i
++ )
340 const HWND hwndBtn
= (*m_radioButtons
)[i
];
341 if ( id
== wxGetWindowId(hwndBtn
) )
343 // we can get BN_CLICKED for a button which just became focused
344 // but it may not be checked, in which case we shouldn't
345 // generate a radiobox selection changed event for it
346 if ( ::SendMessage(hwndBtn
, BM_GETCHECK
, 0, 0) == BST_CHECKED
)
353 if ( selectedButton
== wxNOT_FOUND
)
355 // just ignore it - due to a hack with WM_NCHITTEST handling in our
356 // wnd proc, we can receive dummy click messages when we click near
357 // the radiobox edge (this is ugly but Julian wouldn't let me get
362 if ( selectedButton
!= m_selectedButton
)
364 m_selectedButton
= selectedButton
;
366 SendNotificationEvent();
368 //else: don't generate events when the selection doesn't change
376 void wxRadioBox::Command(wxCommandEvent
& event
)
378 SetSelection (event
.GetInt());
380 ProcessCommand(event
);
383 void wxRadioBox::SendNotificationEvent()
385 wxCommandEvent
event(wxEVT_RADIOBOX
, m_windowId
);
386 event
.SetInt( m_selectedButton
);
387 event
.SetString(GetString(m_selectedButton
));
388 event
.SetEventObject( this );
389 ProcessCommand(event
);
392 // ----------------------------------------------------------------------------
394 // ----------------------------------------------------------------------------
396 unsigned int wxRadioBox::GetCount() const
398 return m_radioButtons
? m_radioButtons
->GetCount() : 0u;
401 void wxRadioBox::SetString(unsigned int item
, const wxString
& label
)
403 wxCHECK_RET( IsValid(item
), wxT("invalid radiobox index") );
406 m_radioHeight
[item
] = wxDefaultCoord
;
408 ::SetWindowText((*m_radioButtons
)[item
], label
.c_str());
410 InvalidateBestSize();
413 void wxRadioBox::SetSelection(int N
)
415 wxCHECK_RET( IsValid(N
), wxT("invalid radiobox index") );
417 // unselect the old button
418 if ( m_selectedButton
!= wxNOT_FOUND
)
419 ::SendMessage((*m_radioButtons
)[m_selectedButton
], BM_SETCHECK
, 0, 0L);
421 // and select the new one
422 ::SendMessage((*m_radioButtons
)[N
], BM_SETCHECK
, 1, 0L);
424 m_selectedButton
= N
;
427 // Find string for position
428 wxString
wxRadioBox::GetString(unsigned int item
) const
430 wxCHECK_MSG( IsValid(item
), wxEmptyString
,
431 wxT("invalid radiobox index") );
433 return wxGetWindowText((*m_radioButtons
)[item
]);
436 void wxRadioBox::SetFocus()
438 if ( GetCount() > 0 )
440 ::SetFocus((*m_radioButtons
)[m_selectedButton
== wxNOT_FOUND
442 : m_selectedButton
]);
446 bool wxRadioBox::CanBeFocused() const
448 // If the control itself is hidden or disabled, no need to check anything
450 if ( !wxStaticBox::CanBeFocused() )
453 // Otherwise, check if we have any buttons that can be focused.
454 for ( size_t item
= 0; item
< m_radioButtons
->GetCount(); item
++ )
456 if ( IsItemEnabled(item
) && IsItemShown(item
) )
460 // We didn't find any items that can accept focus, so neither can we as a
465 // Enable a specific button
466 bool wxRadioBox::Enable(unsigned int item
, bool enable
)
468 wxCHECK_MSG( IsValid(item
), false,
469 wxT("invalid item in wxRadioBox::Enable()") );
471 BOOL ret
= MSWEnableHWND((*m_radioButtons
)[item
], enable
);
473 return (ret
== 0) != enable
;
476 bool wxRadioBox::IsItemEnabled(unsigned int item
) const
478 wxCHECK_MSG( IsValid(item
), false,
479 wxT("invalid item in wxRadioBox::IsItemEnabled()") );
481 return ::IsWindowEnabled((*m_radioButtons
)[item
]) != 0;
484 // Show a specific button
485 bool wxRadioBox::Show(unsigned int item
, bool show
)
487 wxCHECK_MSG( IsValid(item
), false,
488 wxT("invalid item in wxRadioBox::Show()") );
490 BOOL ret
= ::ShowWindow((*m_radioButtons
)[item
], show
? SW_SHOW
: SW_HIDE
);
492 bool changed
= (ret
!= 0) != show
;
495 InvalidateBestSize();
501 bool wxRadioBox::IsItemShown(unsigned int item
) const
503 wxCHECK_MSG( IsValid(item
), false,
504 wxT("invalid item in wxRadioBox::IsItemShown()") );
506 // don't use IsWindowVisible() here because it would return false if the
507 // radiobox itself is hidden while we want to only return false if this
508 // button specifically is hidden
509 return (::GetWindowLong((*m_radioButtons
)[item
],
510 GWL_STYLE
) & WS_VISIBLE
) != 0;
515 bool wxRadioBox::HasToolTips() const
517 return wxStaticBox::HasToolTips() || wxRadioBoxBase::HasItemToolTips();
520 void wxRadioBox::DoSetItemToolTip(unsigned int item
, wxToolTip
*tooltip
)
522 // we have already checked for the item to be valid in wxRadioBoxBase
523 const HWND hwndRbtn
= (*m_radioButtons
)[item
];
524 if ( tooltip
!= NULL
)
525 tooltip
->AddOtherWindow(hwndRbtn
);
526 else // unset the tooltip
527 wxToolTip::Remove(hwndRbtn
, 0, wxRect(0,0,0,0));
528 // the second parameter can be zero since it's ignored by Remove()
529 // as we pass a rect for which wxRect::IsEmpty()==true...
532 #endif // wxUSE_TOOLTIPS
534 bool wxRadioBox::Reparent(wxWindowBase
*newParent
)
536 if ( !wxStaticBox::Reparent(newParent
) )
541 HWND hwndParent
= GetHwndOf(GetParent());
542 for ( size_t item
= 0; item
< m_radioButtons
->GetCount(); item
++ )
544 ::SetParent((*m_radioButtons
)[item
], hwndParent
);
547 // put static box under the buttons in the Z-order
548 SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
553 WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox
, wxStaticBox
, m_radioButtons
)
555 // ----------------------------------------------------------------------------
557 // ----------------------------------------------------------------------------
559 wxSize
wxRadioBox::GetMaxButtonSize() const
561 // calculate the max button size
564 const unsigned int count
= GetCount();
565 for ( unsigned int i
= 0 ; i
< count
; i
++ )
568 if ( m_radioWidth
[i
] < 0 )
570 GetTextExtent(wxGetWindowText((*m_radioButtons
)[i
]), &width
, &height
);
572 // adjust the size to take into account the radio box itself
573 // FIXME this is totally bogus!
580 width
= m_radioWidth
[i
];
581 height
= m_radioHeight
[i
];
584 if ( widthMax
< width
)
586 if ( heightMax
< height
)
590 return wxSize(widthMax
, heightMax
);
593 wxSize
wxRadioBox::GetTotalButtonSize(const wxSize
& sizeBtn
) const
595 // the radiobox should be big enough for its buttons
597 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
599 int extraHeight
= cy1
;
601 int height
= GetRowCount() * sizeBtn
.y
+ cy1
/2 + extraHeight
;
602 int width
= GetColumnCount() * (sizeBtn
.x
+ cx1
) + cx1
;
604 // Add extra space under the label, if it exists.
605 if (!wxControl::GetLabel().empty())
608 // and also wide enough for its label
610 GetTextExtent(GetLabelText(), &widthLabel
, NULL
);
611 widthLabel
+= RADIO_SIZE
; // FIXME this is bogus too
612 if ( widthLabel
> width
)
615 return wxSize(width
, height
);
618 wxSize
wxRadioBox::DoGetBestSize() const
620 if ( !m_radioButtons
)
622 // if we're not fully initialized yet, we can't meaningfully compute
623 // our best size, we'll do it later
627 wxSize best
= GetTotalButtonSize(GetMaxButtonSize());
632 void wxRadioBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
634 if ( (width
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_WIDTH
)) ||
635 (height
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_HEIGHT
)) )
637 // Attempt to have a look coherent with other platforms: We compute the
638 // biggest toggle dim, then we align all items according this value.
639 const wxSize totSize
= GetTotalButtonSize(GetMaxButtonSize());
641 // only change our width/height if asked for
642 if ( width
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_WIDTH
) )
645 if ( height
== wxDefaultCoord
&& (sizeFlags
& wxSIZE_AUTO_HEIGHT
) )
649 wxStaticBox::DoSetSize(x
, y
, width
, height
);
652 void wxRadioBox::DoMoveWindow(int x
, int y
, int width
, int height
)
654 wxStaticBox::DoMoveWindow(x
, y
, width
, height
);
656 PositionAllButtons(x
, y
, width
, height
);
660 wxRadioBox::PositionAllButtons(int x
, int y
, int width
, int WXUNUSED(height
))
662 wxSize maxSize
= GetMaxButtonSize();
663 int maxWidth
= maxSize
.x
,
664 maxHeight
= maxSize
.y
;
666 // Now position all the buttons: the current button will be put at
667 // wxPoint(x_offset, y_offset) and the new row/column will start at
668 // startX/startY. The size of all buttons will be the same wxSize(maxWidth,
669 // maxHeight) except for the buttons in the last column which should extend
670 // to the right border of radiobox and thus can be wider than this.
672 // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in
673 // left to right order and GetMajorDim() is the number of columns while
674 // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and
675 // GetMajorDim() is the number of rows.
678 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
680 int x_offset
= x
+ cx1
;
681 int y_offset
= y
+ cy1
;
683 // Add extra space under the label, if it exists.
684 if (!wxControl::GetLabel().empty())
687 int startX
= x_offset
;
688 int startY
= y_offset
;
690 const unsigned int count
= GetCount();
691 for (unsigned int i
= 0; i
< count
; i
++)
693 // the last button in the row may be wider than the other ones as the
694 // radiobox may be wider than the sum of the button widths (as it
695 // happens, for example, when the radiobox label is very long)
697 if ( m_windowStyle
& wxRA_SPECIFY_COLS
)
699 // item is the last in its row if it is a multiple of the number of
700 // columns or if it is just the last item
701 unsigned int n
= i
+ 1;
702 isLastInTheRow
= ((n
% GetMajorDim()) == 0) || (n
== count
);
704 else // wxRA_SPECIFY_ROWS
706 // item is the last in the row if it is in the last columns
707 isLastInTheRow
= i
>= (count
/GetMajorDim())*GetMajorDim();
710 // is this the start of new row/column?
711 if ( i
&& (i
% GetMajorDim() == 0) )
713 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
715 // start of new column
717 x_offset
+= maxWidth
+ cx1
;
719 else // start of new row
722 y_offset
+= maxHeight
;
723 if (m_radioWidth
[0]>0)
729 if ( isLastInTheRow
)
731 // make the button go to the end of radio box
732 widthBtn
= startX
+ width
- x_offset
- 2*cx1
;
733 if ( widthBtn
< maxWidth
)
738 // normal button, always of the same size
742 // make all buttons of the same, maximal size - like this they cover
743 // the radiobox entirely and the radiobox tooltips are always shown
744 // (otherwise they are not when the mouse pointer is in the radiobox
745 // part not belonging to any radiobutton)
746 DoMoveSibling((*m_radioButtons
)[i
], x_offset
, y_offset
, widthBtn
, maxHeight
);
748 // where do we put the next button?
749 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
752 y_offset
+= maxHeight
;
753 if (m_radioWidth
[0]>0)
758 // to the right of this one
759 x_offset
+= widthBtn
+ cx1
;
764 int wxRadioBox::GetItemFromPoint(const wxPoint
& pt
) const
766 const unsigned int count
= GetCount();
767 for ( unsigned int i
= 0; i
< count
; i
++ )
769 RECT rect
= wxGetWindowRect((*m_radioButtons
)[i
]);
771 if ( rect
.left
<= pt
.x
&& pt
.x
< rect
.right
&&
772 rect
.top
<= pt
.y
&& pt
.y
< rect
.bottom
)
781 // ----------------------------------------------------------------------------
783 // ----------------------------------------------------------------------------
787 WXHRGN
wxRadioBox::MSWGetRegionWithoutChildren()
790 ::GetWindowRect(GetHwnd(), &rc
);
791 HRGN hrgn
= ::CreateRectRgn(rc
.left
, rc
.top
, rc
.right
+ 1, rc
.bottom
+ 1);
793 const unsigned int count
= GetCount();
794 for ( unsigned int i
= 0; i
< count
; ++i
)
796 // don't clip out hidden children
797 if ( !IsItemShown(i
) )
800 ::GetWindowRect((*m_radioButtons
)[i
], &rc
);
801 AutoHRGN
hrgnchild(::CreateRectRgnIndirect(&rc
));
802 ::CombineRgn(hrgn
, hrgn
, hrgnchild
, RGN_DIFF
);
808 #endif // __WXWINCE__
810 // ---------------------------------------------------------------------------
811 // window proc for radio buttons
812 // ---------------------------------------------------------------------------
814 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hwnd
,
820 wxRadioBox
* const radiobox
= wxRadioBox::GetFromRadioButtonHWND(hwnd
);
821 wxCHECK_MSG( radiobox
, 0, wxT("Should have the associated radio box") );
826 // we must tell IsDialogMessage()/our kbd processing code that we
827 // want to process arrows ourselves because neither of them is
828 // smart enough to handle arrows properly for us
830 long lDlgCode
= ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
,
831 message
, wParam
, lParam
);
833 return lDlgCode
| DLGC_WANTARROWS
;
838 bool processed
= true;
862 // just to suppress the compiler warning
868 int selOld
= radiobox
->GetSelection();
869 int selNew
= radiobox
->GetNextItem
873 radiobox
->GetWindowStyle()
876 if ( selNew
!= selOld
)
878 radiobox
->SetSelection(selNew
);
879 radiobox
->SetFocus();
881 // emulate the button click
882 radiobox
->SendNotificationEvent();
893 // if we don't do this, no focus events are generated for the
894 // radiobox and, besides, we need to notify the parent about
895 // the focus change, otherwise the focus handling logic in
896 // wxControlContainer doesn't work
897 if ( message
== WM_SETFOCUS
)
898 radiobox
->HandleSetFocus((WXHWND
)wParam
);
900 radiobox
->HandleKillFocus((WXHWND
)wParam
);
907 bool processed
= false;
909 wxEvtHandler
* const handler
= radiobox
->GetEventHandler();
911 HELPINFO
* info
= (HELPINFO
*) lParam
;
912 if ( info
->iContextType
== HELPINFO_WINDOW
)
914 for ( wxWindow
* subjectOfHelp
= radiobox
;
916 subjectOfHelp
= subjectOfHelp
->GetParent() )
918 wxHelpEvent
helpEvent(wxEVT_HELP
,
919 subjectOfHelp
->GetId(),
920 wxPoint(info
->MousePos
.x
,
922 helpEvent
.SetEventObject(radiobox
);
923 if ( handler
->ProcessEvent(helpEvent
) )
930 else if (info
->iContextType
== HELPINFO_MENUITEM
)
932 wxHelpEvent
helpEvent(wxEVT_HELP
, info
->iCtrlId
);
933 helpEvent
.SetEventObject(radiobox
);
934 processed
= handler
->ProcessEvent(helpEvent
);
941 #endif // !__WXWINCE__
944 return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
, message
, wParam
, lParam
);
947 #endif // wxUSE_RADIOBOX