1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
21 #pragma implementation "radiobox.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/bitmap.h"
36 #include "wx/radiobox.h"
37 #include "wx/settings.h"
41 #include "wx/msw/private.h"
44 #if !defined(__GNUWIN32_OLD__) || defined(__CYGWIN10__)
47 #include "wx/tooltip.h"
48 #endif // wxUSE_TOOLTIPS
50 #if defined(__WXWINCE__) && !defined(WS_EX_TRANSPARENT)
51 #define WS_EX_TRANSPARENT 0
54 // TODO: wxCONSTRUCTOR
55 #if 0 // wxUSE_EXTENDED_RTTI
56 WX_DEFINE_FLAGS( wxRadioBoxStyle
)
58 wxBEGIN_FLAGS( wxRadioBoxStyle
)
59 // new style border flags, we put them first to
60 // use them for streaming out
61 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
62 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
63 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
64 wxFLAGS_MEMBER(wxBORDER_RAISED
)
65 wxFLAGS_MEMBER(wxBORDER_STATIC
)
66 wxFLAGS_MEMBER(wxBORDER_NONE
)
68 // old style border flags
69 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
70 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
71 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
72 wxFLAGS_MEMBER(wxRAISED_BORDER
)
73 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
74 wxFLAGS_MEMBER(wxBORDER
)
76 // standard window styles
77 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
78 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
79 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
80 wxFLAGS_MEMBER(wxWANTS_CHARS
)
81 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
82 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
83 wxFLAGS_MEMBER(wxVSCROLL
)
84 wxFLAGS_MEMBER(wxHSCROLL
)
86 wxFLAGS_MEMBER(wxRA_SPECIFY_COLS
)
87 wxFLAGS_MEMBER(wxRA_HORIZONTAL
)
88 wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS
)
89 wxFLAGS_MEMBER(wxRA_VERTICAL
)
91 wxEND_FLAGS( wxRadioBoxStyle
)
93 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox
, wxControl
,"wx/radiobox.h")
95 wxBEGIN_PROPERTIES_TABLE(wxRadioBox
)
96 wxEVENT_PROPERTY( Select
, wxEVT_COMMAND_RADIOBOX_SELECTED
, wxCommandEvent
)
97 wxPROPERTY_FLAGS( WindowStyle
, wxRadioBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
98 wxEND_PROPERTIES_TABLE()
101 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox
, wxControl
)
112 // there are two possible ways to create the radio buttons: either as children
113 // of the radiobox or as siblings of it - allow playing with both variants for
114 // now, eventually we will choose the best one for our purposes
116 // two main problems are the keyboard navigation inside the radiobox (arrows
117 // should switch between buttons, not pass focus to the next control) and the
118 // tooltips - a tooltip is associated with the radiobox itself, not the
121 // the problems with setting this to 1:
122 // a) Alt-<mnemonic of radiobox> isn't handled properly by IsDialogMessage()
123 // because it sets focus to the next control accepting it which is not a
124 // radio button but a radiobox sibling in this case - the only solution to
125 // this would be to handle Alt-<mnemonic> ourselves
126 // b) the problems with setting radiobox colours under Win98/2K were reported
127 // but I couldn't reproduce it so I have no idea about what causes it
129 // the problems with setting this to 0:
130 // a) the tooltips are not shown for the radiobox - possible solution: make
131 // TTM_WINDOWFROMPOS handling code in msw/tooltip.cpp work (easier said than
132 // done because I don't know why it doesn't work)
133 #define RADIOBTN_PARENT_IS_RADIOBOX 0
135 // ---------------------------------------------------------------------------
137 // ---------------------------------------------------------------------------
139 // wnd proc for radio buttons
141 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hWnd
,
146 // ---------------------------------------------------------------------------
148 // ---------------------------------------------------------------------------
150 // the pointer to standard radio button wnd proc
151 static WXFARPROC s_wndprocRadioBtn
= (WXFARPROC
)NULL
;
155 // ===========================================================================
157 // ===========================================================================
159 // ---------------------------------------------------------------------------
161 // ---------------------------------------------------------------------------
163 int wxRadioBox::GetCount() const
168 int wxRadioBox::GetColumnCount() const
173 int wxRadioBox::GetRowCount() const
178 // returns the number of rows
179 int wxRadioBox::GetNumVer() const
181 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
187 return (m_noItems
+ m_majorDim
- 1)/m_majorDim
;
191 // returns the number of columns
192 int wxRadioBox::GetNumHor() const
194 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
196 return (m_noItems
+ m_majorDim
- 1)/m_majorDim
;
204 bool wxRadioBox::MSWCommand(WXUINT cmd
, WXWORD id
)
206 if ( cmd
== BN_CLICKED
)
211 int selectedButton
= wxID_ANY
;
213 for ( int i
= 0; i
< m_noItems
; i
++ )
215 if ( id
== wxGetWindowId(m_radioButtons
[i
]) )
223 if ( selectedButton
== wxID_ANY
)
225 // just ignore it - due to a hack with WM_NCHITTEST handling in our
226 // wnd proc, we can receive dummy click messages when we click near
227 // the radiobox edge (this is ugly but Julian wouldn't let me get
232 if ( selectedButton
!= m_selectedButton
)
234 m_selectedButton
= selectedButton
;
236 SendNotificationEvent();
238 //else: don't generate events when the selection doesn't change
247 wxRadioBox::wxRadioBox()
249 m_selectedButton
= wxID_ANY
;
252 m_radioButtons
= NULL
;
255 m_radioHeight
= NULL
;
258 bool wxRadioBox::Create(wxWindow
*parent
,
260 const wxString
& title
,
264 const wxString choices
[],
267 const wxValidator
& val
,
268 const wxString
& name
)
270 // initialize members
271 m_selectedButton
= wxID_ANY
;
274 m_majorDim
= majorDim
== 0 ? n
: majorDim
;
275 m_noRowsOrCols
= majorDim
;
277 // common initialization
278 if ( !CreateControl(parent
, id
, pos
, size
, style
, val
, name
) )
281 // create the static box
282 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
| WS_GROUP
,
283 pos
, size
, title
, WS_EX_TRANSPARENT
) )
286 // and now create the buttons
288 #if RADIOBTN_PARENT_IS_RADIOBOX
289 HWND hwndParent
= GetHwnd();
291 HWND hwndParent
= GetHwndOf(parent
);
294 // Some radio boxes test consecutive id.
295 (void)NewControlId();
296 m_radioButtons
= new WXHWND
[n
];
297 m_radioWidth
= new int[n
];
298 m_radioHeight
= new int[n
];
301 wxFont font
= GetFont();
304 hfont
= font
.GetResourceHandle();
307 for ( int i
= 0; i
< n
; i
++ )
310 m_radioHeight
[i
] = wxDefaultCoord
;
311 long styleBtn
= BS_AUTORADIOBUTTON
| WS_TABSTOP
| WS_CHILD
| WS_VISIBLE
;
312 if ( i
== 0 && style
== 0 )
313 styleBtn
|= WS_GROUP
;
315 long newId
= NewControlId();
317 HWND hwndBtn
= ::CreateWindow(_T("BUTTON"),
320 0, 0, 0, 0, // will be set in SetSize()
328 wxLogLastError(wxT("CreateWindow(radio btn)"));
333 m_radioButtons
[i
] = (WXHWND
)hwndBtn
;
335 SubclassRadioButton((WXHWND
)hwndBtn
);
339 ::SendMessage(hwndBtn
, WM_SETFONT
, (WPARAM
)hfont
, 0L);
342 m_subControls
.Add(newId
);
345 // Create a dummy radio control to end the group.
346 (void)::CreateWindow(_T("BUTTON"),
348 WS_GROUP
| BS_AUTORADIOBUTTON
| WS_CHILD
,
349 0, 0, 0, 0, hwndParent
,
350 (HMENU
)NewControlId(), wxGetInstance(), NULL
);
353 // Set the z-order correctly
354 SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
358 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
360 // Now that we have items determine what is the best size and set it.
366 bool wxRadioBox::Create(wxWindow
*parent
,
368 const wxString
& title
,
371 const wxArrayString
& choices
,
374 const wxValidator
& val
,
375 const wxString
& name
)
377 wxCArrayString
chs(choices
);
378 return Create(parent
, id
, title
, pos
, size
, chs
.GetCount(),
379 chs
.GetStrings(), majorDim
, style
, val
, name
);
382 wxRadioBox::~wxRadioBox()
384 m_isBeingDeleted
= true;
389 for (i
= 0; i
< m_noItems
; i
++)
390 ::DestroyWindow((HWND
)m_radioButtons
[i
]);
391 delete[] m_radioButtons
;
395 delete[] m_radioWidth
;
397 delete[] m_radioHeight
;
401 void wxRadioBox::SetString(int item
, const wxString
& label
)
403 wxCHECK_RET( item
>= 0 && item
< m_noItems
, wxT("invalid radiobox index") );
405 m_radioWidth
[item
] = m_radioHeight
[item
] = wxDefaultCoord
;
406 SetWindowText((HWND
)m_radioButtons
[item
], label
.c_str());
409 void wxRadioBox::SetSelection(int N
)
411 wxCHECK_RET( (N
>= 0) && (N
< m_noItems
), wxT("invalid radiobox index") );
413 // Following necessary for Win32s, because Win32s translate BM_SETCHECK
414 if (m_selectedButton
>= 0 && m_selectedButton
< m_noItems
)
415 ::SendMessage((HWND
) m_radioButtons
[m_selectedButton
], BM_SETCHECK
, 0, 0L);
417 ::SendMessage((HWND
)m_radioButtons
[N
], BM_SETCHECK
, 1, 0L);
419 m_selectedButton
= N
;
422 // Get single selection, for single choice list items
423 int wxRadioBox::GetSelection() const
425 return m_selectedButton
;
428 // Find string for position
429 wxString
wxRadioBox::GetString(int item
) const
431 wxCHECK_MSG( item
>= 0 && item
< m_noItems
, wxEmptyString
,
432 wxT("invalid radiobox index") );
434 return wxGetWindowText(m_radioButtons
[item
]);
437 // ----------------------------------------------------------------------------
439 // ----------------------------------------------------------------------------
441 wxSize
wxRadioBox::GetMaxButtonSize() const
443 // calculate the max button size
446 for ( int i
= 0 ; i
< m_noItems
; i
++ )
449 if ( m_radioWidth
[i
] < 0 )
451 GetTextExtent(wxGetWindowText(m_radioButtons
[i
]), &width
, &height
);
453 // adjust the size to take into account the radio box itself
454 // FIXME this is totally bogus!
461 width
= m_radioWidth
[i
];
462 height
= m_radioHeight
[i
];
465 if ( widthMax
< width
)
467 if ( heightMax
< height
)
471 return wxSize(widthMax
, heightMax
);
474 wxSize
wxRadioBox::GetTotalButtonSize(const wxSize
& sizeBtn
) const
476 // the radiobox should be big enough for its buttons
478 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
480 int extraHeight
= cy1
;
482 /* We'll assume the adjustments below are OK for Win 3.1 too
483 #if defined(CTL3D) && !CTL3D
484 // Requires a bigger group box in plain Windows
490 int height
= GetNumVer() * sizeBtn
.y
+ cy1
/2 + extraHeight
;
491 int width
= GetNumHor() * (sizeBtn
.x
+ cx1
) + cx1
;
493 // Add extra space under the label, if it exists.
494 if (!wxControl::GetLabel().IsEmpty())
497 // and also wide enough for its label
499 GetTextExtent(GetTitle(), &widthLabel
, NULL
);
500 widthLabel
+= RADIO_SIZE
; // FIXME this is bogus too
501 if ( widthLabel
> width
)
504 return wxSize(width
, height
);
507 wxSize
wxRadioBox::DoGetBestSize() const
509 return GetTotalButtonSize(GetMaxButtonSize());
512 // Restored old code.
513 void wxRadioBox::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
515 int currentX
, currentY
;
516 GetPosition(¤tX
, ¤tY
);
517 int widthOld
, heightOld
;
518 GetSize(&widthOld
, &heightOld
);
523 if (x
== wxDefaultCoord
&& !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
525 if (y
== wxDefaultCoord
&& !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
528 #if RADIOBTN_PARENT_IS_RADIOBOX
537 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
539 // Attempt to have a look coherent with other platforms: We compute the
540 // biggest toggle dim, then we align all items according this value.
541 wxSize maxSize
= GetMaxButtonSize();
542 int maxWidth
= maxSize
.x
,
543 maxHeight
= maxSize
.y
;
545 wxSize totSize
= GetTotalButtonSize(maxSize
);
546 int totWidth
= totSize
.x
,
547 totHeight
= totSize
.y
;
549 // only change our width/height if asked for
550 if ( width
== wxDefaultCoord
)
552 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
558 if ( height
== wxDefaultCoord
)
560 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
566 ::MoveWindow(GetHwnd(), xx
, yy
, width
, height
, TRUE
);
568 // Now position all the buttons: the current button will be put at
569 // wxPoint(x_offset, y_offset) and the new row/column will start at
570 // startX/startY. The size of all buttons will be the same wxSize(maxWidth,
571 // maxHeight) except for the buttons in the last column which should extend
572 // to the right border of radiobox and thus can be wider than this.
574 // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in
575 // left to right order and m_majorDim is the number of columns while
576 // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and
577 // m_majorDim is the number of rows.
582 // Add extra space under the label, if it exists.
583 if (!wxControl::GetLabel().IsEmpty())
586 int startX
= x_offset
;
587 int startY
= y_offset
;
589 for ( int i
= 0; i
< m_noItems
; i
++ )
591 // the last button in the row may be wider than the other ones as the
592 // radiobox may be wider than the sum of the button widths (as it
593 // happens, for example, when the radiobox label is very long)
595 if ( m_windowStyle
& wxRA_SPECIFY_COLS
)
597 // item is the last in its row if it is a multiple of the number of
598 // columns or if it is just the last item
600 isLastInTheRow
= ((n
% m_majorDim
) == 0) || (n
== m_noItems
);
602 else // wxRA_SPECIFY_ROWS
604 // item is the last in the row if it is in the last columns
605 isLastInTheRow
= i
>= (m_noItems
/m_majorDim
)*m_majorDim
;
608 // is this the start of new row/column?
609 if ( i
&& (i
% m_majorDim
== 0) )
611 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
613 // start of new column
615 x_offset
+= maxWidth
+ cx1
;
617 else // start of new row
620 y_offset
+= maxHeight
;
621 if (m_radioWidth
[0]>0)
627 if ( isLastInTheRow
)
629 // make the button go to the end of radio box
630 widthBtn
= startX
+ width
- x_offset
- 2*cx1
;
631 if ( widthBtn
< maxWidth
)
636 // normal button, always of the same size
640 // VZ: make all buttons of the same, maximal size - like this they
641 // cover the radiobox entirely and the radiobox tooltips are always
642 // shown (otherwise they are not when the mouse pointer is in the
643 // radiobox part not belonging to any radiobutton)
644 ::MoveWindow((HWND
)m_radioButtons
[i
],
645 x_offset
, y_offset
, widthBtn
, maxHeight
,
648 // where do we put the next button?
649 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
652 y_offset
+= maxHeight
;
653 if (m_radioWidth
[0]>0)
658 // to the right of this one
659 x_offset
+= widthBtn
+ cx1
;
664 void wxRadioBox::GetSize(int *width
, int *height
) const
666 RECT rect
= { -1, -1, -1, -1 };
669 wxFindMaxSize(m_hWnd
, &rect
);
672 for (i
= 0; i
< m_noItems
; i
++)
673 wxFindMaxSize(m_radioButtons
[i
], &rect
);
675 *width
= rect
.right
- rect
.left
;
676 *height
= rect
.bottom
- rect
.top
;
679 void wxRadioBox::GetPosition(int *x
, int *y
) const
681 wxWindow
*parent
= GetParent();
682 RECT rect
= { -1, -1, -1, -1 };
685 for (i
= 0; i
< m_noItems
; i
++)
686 wxFindMaxSize(m_radioButtons
[i
], &rect
);
689 wxFindMaxSize(m_hWnd
, &rect
);
691 // Since we now have the absolute screen coords, if there's a parent we
692 // must subtract its top left corner
698 ::ScreenToClient((HWND
) parent
->GetHWND(), &point
);
701 // We may be faking the client origin. So a window that's really at (0, 30)
702 // may appear (to wxWin apps) to be at (0, 0).
705 wxPoint
pt(GetParent()->GetClientAreaOrigin());
714 void wxRadioBox::SetFocus()
718 ::SetFocus((HWND
)m_radioButtons
[m_selectedButton
== wxID_ANY
720 : m_selectedButton
]);
725 bool wxRadioBox::Show(bool show
)
727 if ( !wxControl::Show(show
) )
730 int nCmdShow
= show
? SW_SHOW
: SW_HIDE
;
731 for ( int i
= 0; i
< m_noItems
; i
++ )
733 ::ShowWindow((HWND
)m_radioButtons
[i
], nCmdShow
);
739 // Enable a specific button
740 void wxRadioBox::Enable(int item
, bool enable
)
742 wxCHECK_RET( item
>= 0 && item
< m_noItems
,
743 wxT("invalid item in wxRadioBox::Enable()") );
745 ::EnableWindow((HWND
) m_radioButtons
[item
], enable
);
748 // Enable all controls
749 bool wxRadioBox::Enable(bool enable
)
751 if ( !wxControl::Enable(enable
) )
754 for (int i
= 0; i
< m_noItems
; i
++)
755 ::EnableWindow((HWND
) m_radioButtons
[i
], enable
);
760 // Show a specific button
761 void wxRadioBox::Show(int item
, bool show
)
763 wxCHECK_RET( item
>= 0 && item
< m_noItems
,
764 wxT("invalid item in wxRadioBox::Show()") );
766 ::ShowWindow((HWND
)m_radioButtons
[item
], show
? SW_SHOW
: SW_HIDE
);
769 bool wxRadioBox::ContainsHWND(WXHWND hWnd
) const
771 size_t count
= GetCount();
772 for ( size_t i
= 0; i
< count
; i
++ )
774 if ( GetRadioButtons()[i
] == hWnd
)
781 void wxRadioBox::Command(wxCommandEvent
& event
)
783 SetSelection (event
.m_commandInt
);
785 ProcessCommand (event
);
788 // NB: if this code is changed, wxGetWindowForHWND() which relies on having the
789 // radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
790 void wxRadioBox::SubclassRadioButton(WXHWND hWndBtn
)
792 HWND hwndBtn
= (HWND
)hWndBtn
;
794 if ( !s_wndprocRadioBtn
)
795 s_wndprocRadioBtn
= (WXFARPROC
)wxGetWindowProc(hwndBtn
);
797 wxSetWindowProc(hwndBtn
, wxRadioBtnWndProc
);
798 wxSetWindowUserData(hwndBtn
, this);
801 void wxRadioBox::SendNotificationEvent()
803 wxCommandEvent
event(wxEVT_COMMAND_RADIOBOX_SELECTED
, m_windowId
);
804 event
.SetInt( m_selectedButton
);
805 event
.SetString( GetString(m_selectedButton
) );
806 event
.SetEventObject( this );
807 ProcessCommand(event
);
810 bool wxRadioBox::SetFont(const wxFont
& font
)
812 if ( !wxControl::SetFont(font
) )
818 // also set the font of our radio buttons
819 WXHFONT hfont
= wxFont(font
).GetResourceHandle();
820 for ( int n
= 0; n
< m_noItems
; n
++ )
822 HWND hwndBtn
= (HWND
)m_radioButtons
[n
];
823 ::SendMessage(hwndBtn
, WM_SETFONT
, (WPARAM
)hfont
, 0L);
825 // otherwise the buttons are not redrawn correctly
826 ::InvalidateRect(hwndBtn
, NULL
, FALSE
/* don't erase bg */);
832 // ----------------------------------------------------------------------------
834 // ----------------------------------------------------------------------------
836 WXLRESULT
wxRadioBox::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
838 #if RADIOBTN_PARENT_IS_RADIOBOX
841 // handle this message to set correct colours for our buttons here
842 case WM_CTLCOLORSTATIC
:
846 UnpackCtlColor(wParam
, lParam
, &hdc
, &hwnd
);
848 WXHBRUSH hbr
= MSWControlColor((WXHDC
)hdc
);
850 return (WXLRESULT
)hbr
;
851 //else: fall through to default window proc
854 #endif // RADIOBTN_PARENT_IS_RADIOBOX
856 return wxControl::MSWWindowProc(nMsg
, wParam
, lParam
);
859 // ---------------------------------------------------------------------------
860 // window proc for radio buttons
861 // ---------------------------------------------------------------------------
865 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hwnd
,
873 // we must tell IsDialogMessage()/our kbd processing code that we
874 // want to process arrows ourselves because neither of them is
875 // smart enough to handle arrows properly for us
877 long lDlgCode
= ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
,
878 message
, wParam
, lParam
);
880 return lDlgCode
| DLGC_WANTARROWS
;
886 NMHDR
* hdr
= (NMHDR
*)lParam
;
887 if ( hdr
->code
== TTN_NEEDTEXT
)
890 radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
892 wxCHECK_MSG( radiobox
, 0,
893 wxT("radio button without radio box?") );
895 wxToolTip
*tooltip
= radiobox
->GetToolTip();
898 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
899 ttt
->lpszText
= (wxChar
*)tooltip
->GetTip().c_str();
907 #endif // wxUSE_TOOLTIPS
911 wxRadioBox
*radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
913 wxCHECK_MSG( radiobox
, 0, wxT("radio button without radio box?") );
915 bool processed
= true;
939 // just to suppress the compiler warning
945 int selOld
= radiobox
->GetSelection();
946 int selNew
= radiobox
->GetNextItem
950 radiobox
->GetWindowStyle()
953 if ( selNew
!= selOld
)
955 radiobox
->SetSelection(selNew
);
956 radiobox
->SetFocus();
958 // emulate the button click
959 radiobox
->SendNotificationEvent();
970 wxRadioBox
*radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
972 wxCHECK_MSG( radiobox
, 0, wxT("radio button without radio box?") );
974 // if we don't do this, no focus events are generated for the
975 // radiobox and, besides, we need to notify the parent about
976 // the focus change, otherwise the focus handling logic in
977 // wxControlContainer doesn't work
978 if ( message
== WM_SETFOCUS
)
979 radiobox
->HandleSetFocus((WXHWND
)wParam
);
981 radiobox
->HandleKillFocus((WXHWND
)wParam
);
988 wxRadioBox
*radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
990 wxCHECK_MSG( radiobox
, 0, wxT("radio button without radio box?") );
992 bool processed
wxDUMMY_INITIALIZE(true);
994 // HELPINFO doesn't seem to be supported on WinCE.
996 HELPINFO
* info
= (HELPINFO
*) lParam
;
997 // Don't yet process menu help events, just windows
998 if (info
->iContextType
== HELPINFO_WINDOW
)
1001 wxWindow
* subjectOfHelp
= radiobox
;
1002 bool eventProcessed
= false;
1003 while (subjectOfHelp
&& !eventProcessed
)
1005 wxHelpEvent
helpEvent(wxEVT_HELP
, subjectOfHelp
->GetId(),
1009 wxPoint(info
->MousePos
.x
, info
->MousePos
.y
)
1011 ) ; // info->iCtrlId);
1012 helpEvent
.SetEventObject(radiobox
);
1013 eventProcessed
= radiobox
->GetEventHandler()->ProcessEvent(helpEvent
);
1015 // Go up the window hierarchy until the event is handled (or not)
1016 subjectOfHelp
= subjectOfHelp
->GetParent();
1018 processed
= eventProcessed
;
1021 else if (info
->iContextType
== HELPINFO_MENUITEM
)
1023 wxHelpEvent
helpEvent(wxEVT_HELP
, info
->iCtrlId
) ;
1024 helpEvent
.SetEventObject(radiobox
);
1025 processed
= radiobox
->GetEventHandler()->ProcessEvent(helpEvent
);
1038 return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
, message
, wParam
, lParam
);
1043 #endif // wxUSE_RADIOBOX