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/notebook.h"
43 #include "wx/msw/private.h"
46 #if !defined(__GNUWIN32_OLD__) || defined(__CYGWIN10__)
49 #include "wx/tooltip.h"
50 #endif // wxUSE_TOOLTIPS
52 // TODO: wxCONSTRUCTOR
53 #if 0 // wxUSE_EXTENDED_RTTI
54 WX_DEFINE_FLAGS( wxRadioBoxStyle
)
56 wxBEGIN_FLAGS( wxRadioBoxStyle
)
57 // new style border flags, we put them first to
58 // use them for streaming out
59 wxFLAGS_MEMBER(wxBORDER_SIMPLE
)
60 wxFLAGS_MEMBER(wxBORDER_SUNKEN
)
61 wxFLAGS_MEMBER(wxBORDER_DOUBLE
)
62 wxFLAGS_MEMBER(wxBORDER_RAISED
)
63 wxFLAGS_MEMBER(wxBORDER_STATIC
)
64 wxFLAGS_MEMBER(wxBORDER_NONE
)
66 // old style border flags
67 wxFLAGS_MEMBER(wxSIMPLE_BORDER
)
68 wxFLAGS_MEMBER(wxSUNKEN_BORDER
)
69 wxFLAGS_MEMBER(wxDOUBLE_BORDER
)
70 wxFLAGS_MEMBER(wxRAISED_BORDER
)
71 wxFLAGS_MEMBER(wxSTATIC_BORDER
)
72 wxFLAGS_MEMBER(wxBORDER
)
74 // standard window styles
75 wxFLAGS_MEMBER(wxTAB_TRAVERSAL
)
76 wxFLAGS_MEMBER(wxCLIP_CHILDREN
)
77 wxFLAGS_MEMBER(wxTRANSPARENT_WINDOW
)
78 wxFLAGS_MEMBER(wxWANTS_CHARS
)
79 wxFLAGS_MEMBER(wxFULL_REPAINT_ON_RESIZE
)
80 wxFLAGS_MEMBER(wxALWAYS_SHOW_SB
)
81 wxFLAGS_MEMBER(wxVSCROLL
)
82 wxFLAGS_MEMBER(wxHSCROLL
)
84 wxFLAGS_MEMBER(wxRA_SPECIFY_COLS
)
85 wxFLAGS_MEMBER(wxRA_HORIZONTAL
)
86 wxFLAGS_MEMBER(wxRA_SPECIFY_ROWS
)
87 wxFLAGS_MEMBER(wxRA_VERTICAL
)
89 wxEND_FLAGS( wxRadioBoxStyle
)
91 IMPLEMENT_DYNAMIC_CLASS_XTI(wxRadioBox
, wxControl
,"wx/radiobox.h")
93 wxBEGIN_PROPERTIES_TABLE(wxRadioBox
)
94 wxEVENT_PROPERTY( Select
, wxEVT_COMMAND_RADIOBOX_SELECTED
, wxCommandEvent
)
95 wxPROPERTY_FLAGS( WindowStyle
, wxRadioBoxStyle
, long , SetWindowStyleFlag
, GetWindowStyleFlag
, , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // style
96 wxEND_PROPERTIES_TABLE()
99 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox
, wxControl
)
110 // there are two possible ways to create the radio buttons: either as children
111 // of the radiobox or as siblings of it - allow playing with both variants for
112 // now, eventually we will choose the best one for our purposes
114 // two main problems are the keyboard navigation inside the radiobox (arrows
115 // should switch between buttons, not pass focus to the next control) and the
116 // tooltips - a tooltip is associated with the radiobox itself, not the
119 // the problems with setting this to 1:
120 // a) Alt-<mnemonic of radiobox> isn't handled properly by IsDialogMessage()
121 // because it sets focus to the next control accepting it which is not a
122 // radio button but a radiobox sibling in this case - the only solution to
123 // this would be to handle Alt-<mnemonic> ourselves
124 // b) the problems with setting radiobox colours under Win98/2K were reported
125 // but I couldn't reproduce it so I have no idea about what causes it
127 // the problems with setting this to 0:
128 // a) the tooltips are not shown for the radiobox - possible solution: make
129 // TTM_WINDOWFROMPOS handling code in msw/tooltip.cpp work (easier said than
130 // done because I don't know why it doesn't work)
131 #define RADIOBTN_PARENT_IS_RADIOBOX 0
133 // ---------------------------------------------------------------------------
135 // ---------------------------------------------------------------------------
137 // wnd proc for radio buttons
139 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hWnd
,
144 // ---------------------------------------------------------------------------
146 // ---------------------------------------------------------------------------
148 // the pointer to standard radio button wnd proc
149 static WXFARPROC s_wndprocRadioBtn
= (WXFARPROC
)NULL
;
153 // ===========================================================================
155 // ===========================================================================
157 // ---------------------------------------------------------------------------
159 // ---------------------------------------------------------------------------
161 int wxRadioBox
::GetCount() const
166 int wxRadioBox
::GetColumnCount() const
171 int wxRadioBox
::GetRowCount() const
176 // returns the number of rows
177 int wxRadioBox
::GetNumVer() const
179 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
185 return (m_noItems
+ m_majorDim
- 1)/m_majorDim
;
189 // returns the number of columns
190 int wxRadioBox
::GetNumHor() const
192 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
194 return (m_noItems
+ m_majorDim
- 1)/m_majorDim
;
202 bool wxRadioBox
::MSWCommand(WXUINT cmd
, WXWORD id
)
204 if ( cmd
== BN_CLICKED
)
209 int selectedButton
= wxID_ANY
;
211 for ( int i
= 0; i
< m_noItems
; i
++ )
213 if ( id
== wxGetWindowId(m_radioButtons
[i
]) )
221 if ( selectedButton
== wxID_ANY
)
223 // just ignore it - due to a hack with WM_NCHITTEST handling in our
224 // wnd proc, we can receive dummy click messages when we click near
225 // the radiobox edge (this is ugly but Julian wouldn't let me get
230 if ( selectedButton
!= m_selectedButton
)
232 m_selectedButton
= selectedButton
;
234 SendNotificationEvent();
236 //else: don't generate events when the selection doesn't change
245 wxRadioBox
::wxRadioBox()
247 m_selectedButton
= wxID_ANY
;
250 m_radioButtons
= NULL
;
253 m_radioHeight
= NULL
;
256 bool wxRadioBox
::Create(wxWindow
*parent
,
258 const wxString
& title
,
262 const wxString choices
[],
265 const wxValidator
& val
,
266 const wxString
& name
)
268 // initialize members
269 m_selectedButton
= wxID_ANY
;
272 m_majorDim
= majorDim
== 0 ? n
: majorDim
;
273 m_noRowsOrCols
= majorDim
;
275 // common initialization
276 if ( !CreateControl(parent
, id
, pos
, size
, style
, val
, name
) )
279 // create the static box
280 if ( !MSWCreateControl(wxT("BUTTON"), BS_GROUPBOX
| WS_GROUP
,
281 pos
, size
, title
, WS_EX_TRANSPARENT
) )
284 // and now create the buttons
286 #if RADIOBTN_PARENT_IS_RADIOBOX
287 HWND hwndParent
= GetHwnd();
289 HWND hwndParent
= GetHwndOf(parent
);
292 // Some radio boxes test consecutive id.
293 (void)NewControlId();
294 m_radioButtons
= new WXHWND
[n
];
295 m_radioWidth
= new int[n
];
296 m_radioHeight
= new int[n
];
299 wxFont font
= GetFont();
302 hfont
= font
.GetResourceHandle();
305 for ( int i
= 0; i
< n
; i
++ )
308 m_radioHeight
[i
] = wxDefaultCoord
;
309 long styleBtn
= BS_AUTORADIOBUTTON
| WS_TABSTOP
| WS_CHILD
| WS_VISIBLE
;
310 if ( i
== 0 && style
== 0 )
311 styleBtn
|= WS_GROUP
;
313 long newId
= NewControlId();
315 HWND hwndBtn
= ::CreateWindow(_T("BUTTON"),
318 0, 0, 0, 0, // will be set in SetSize()
326 wxLogLastError(wxT("CreateWindow(radio btn)"));
331 m_radioButtons
[i
] = (WXHWND
)hwndBtn
;
333 SubclassRadioButton((WXHWND
)hwndBtn
);
337 ::SendMessage(hwndBtn
, WM_SETFONT
, (WPARAM
)hfont
, 0L);
340 m_subControls
.Add(newId
);
343 // Create a dummy radio control to end the group.
344 (void)::CreateWindow(_T("BUTTON"),
346 WS_GROUP
| BS_AUTORADIOBUTTON
| WS_CHILD
,
347 0, 0, 0, 0, hwndParent
,
348 (HMENU
)NewControlId(), wxGetInstance(), NULL
);
351 // Set the z-order correctly
352 SetWindowPos(GetHwnd(), HWND_BOTTOM
, 0, 0, 0, 0, SWP_NOMOVE
|SWP_NOSIZE
);
356 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
358 // Now that we have items determine what is the best size and set it.
364 bool wxRadioBox
::Create(wxWindow
*parent
,
366 const wxString
& title
,
369 const wxArrayString
& choices
,
372 const wxValidator
& val
,
373 const wxString
& name
)
375 wxCArrayString
chs(choices
);
376 return Create(parent
, id
, title
, pos
, size
, chs
.GetCount(),
377 chs
.GetStrings(), majorDim
, style
, val
, name
);
380 wxRadioBox
::~wxRadioBox()
382 m_isBeingDeleted
= true;
387 for (i
= 0; i
< m_noItems
; i
++)
388 ::DestroyWindow((HWND
)m_radioButtons
[i
]);
389 delete[] m_radioButtons
;
393 delete[] m_radioWidth
;
395 delete[] m_radioHeight
;
399 void wxRadioBox
::SetString(int item
, const wxString
& label
)
401 wxCHECK_RET( item
>= 0 && item
< m_noItems
, wxT("invalid radiobox index") );
403 m_radioWidth
[item
] = m_radioHeight
[item
] = wxDefaultCoord
;
404 SetWindowText((HWND
)m_radioButtons
[item
], label
.c_str());
407 void wxRadioBox
::SetSelection(int N
)
409 wxCHECK_RET( (N
>= 0) && (N
< m_noItems
), wxT("invalid radiobox index") );
411 // Following necessary for Win32s, because Win32s translate BM_SETCHECK
412 if (m_selectedButton
>= 0 && m_selectedButton
< m_noItems
)
413 ::SendMessage((HWND
) m_radioButtons
[m_selectedButton
], BM_SETCHECK
, 0, 0L);
415 ::SendMessage((HWND
)m_radioButtons
[N
], BM_SETCHECK
, 1, 0L);
417 m_selectedButton
= N
;
420 // Get single selection, for single choice list items
421 int wxRadioBox
::GetSelection() const
423 return m_selectedButton
;
426 // Find string for position
427 wxString wxRadioBox
::GetString(int item
) const
429 wxCHECK_MSG( item
>= 0 && item
< m_noItems
, wxEmptyString
,
430 wxT("invalid radiobox index") );
432 return wxGetWindowText(m_radioButtons
[item
]);
435 // ----------------------------------------------------------------------------
437 // ----------------------------------------------------------------------------
439 wxSize wxRadioBox
::GetMaxButtonSize() const
441 // calculate the max button size
444 for ( int i
= 0 ; i
< m_noItems
; i
++ )
447 if ( m_radioWidth
[i
] < 0 )
449 GetTextExtent(wxGetWindowText(m_radioButtons
[i
]), &width
, &height
);
451 // adjust the size to take into account the radio box itself
452 // FIXME this is totally bogus!
459 width
= m_radioWidth
[i
];
460 height
= m_radioHeight
[i
];
463 if ( widthMax
< width
)
465 if ( heightMax
< height
)
469 return wxSize(widthMax
, heightMax
);
472 wxSize wxRadioBox
::GetTotalButtonSize(const wxSize
& sizeBtn
) const
474 // the radiobox should be big enough for its buttons
476 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
478 int extraHeight
= cy1
;
480 /* We'll assume the adjustments below are OK for Win 3.1 too
481 #if defined(CTL3D) && !CTL3D
482 // Requires a bigger group box in plain Windows
488 int height
= GetNumVer() * sizeBtn
.y
+ cy1
/2 + extraHeight
;
489 int width
= GetNumHor() * (sizeBtn
.x
+ cx1
) + cx1
;
491 // Add extra space under the label, if it exists.
492 if (!wxControl
::GetLabel().IsEmpty())
495 // and also wide enough for its label
497 GetTextExtent(GetTitle(), &widthLabel
, NULL
);
498 widthLabel
+= RADIO_SIZE
; // FIXME this is bogus too
499 if ( widthLabel
> width
)
502 return wxSize(width
, height
);
505 wxSize wxRadioBox
::DoGetBestSize() const
507 return GetTotalButtonSize(GetMaxButtonSize());
510 // Restored old code.
511 void wxRadioBox
::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
513 int currentX
, currentY
;
514 GetPosition(¤tX
, ¤tY
);
515 int widthOld
, heightOld
;
516 GetSize(&widthOld
, &heightOld
);
521 if (x
== wxDefaultCoord
&& !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
523 if (y
== wxDefaultCoord
&& !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
526 #if RADIOBTN_PARENT_IS_RADIOBOX
535 wxGetCharSize(m_hWnd
, &cx1
, &cy1
, GetFont());
537 // Attempt to have a look coherent with other platforms: We compute the
538 // biggest toggle dim, then we align all items according this value.
539 wxSize maxSize
= GetMaxButtonSize();
540 int maxWidth
= maxSize
.x
,
541 maxHeight
= maxSize
.y
;
543 wxSize totSize
= GetTotalButtonSize(maxSize
);
544 int totWidth
= totSize
.x
,
545 totHeight
= totSize
.y
;
547 // only change our width/height if asked for
548 if ( width
== wxDefaultCoord
)
550 if ( sizeFlags
& wxSIZE_AUTO_WIDTH
)
556 if ( height
== wxDefaultCoord
)
558 if ( sizeFlags
& wxSIZE_AUTO_HEIGHT
)
564 ::MoveWindow(GetHwnd(), xx
, yy
, width
, height
, TRUE
);
566 // Now position all the buttons: the current button will be put at
567 // wxPoint(x_offset, y_offset) and the new row/column will start at
568 // startX/startY. The size of all buttons will be the same wxSize(maxWidth,
569 // maxHeight) except for the buttons in the last column which should extend
570 // to the right border of radiobox and thus can be wider than this.
572 // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in
573 // left to right order and m_majorDim is the number of columns while
574 // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and
575 // m_majorDim is the number of rows.
580 // Add extra space under the label, if it exists.
581 if (!wxControl
::GetLabel().IsEmpty())
584 int startX
= x_offset
;
585 int startY
= y_offset
;
587 for ( int i
= 0; i
< m_noItems
; i
++ )
589 // the last button in the row may be wider than the other ones as the
590 // radiobox may be wider than the sum of the button widths (as it
591 // happens, for example, when the radiobox label is very long)
593 if ( m_windowStyle
& wxRA_SPECIFY_COLS
)
595 // item is the last in its row if it is a multiple of the number of
596 // columns or if it is just the last item
598 isLastInTheRow
= ((n
% m_majorDim
) == 0) || (n
== m_noItems
);
600 else // wxRA_SPECIFY_ROWS
602 // item is the last in the row if it is in the last columns
603 isLastInTheRow
= i
>= (m_noItems
/m_majorDim
)*m_majorDim
;
606 // is this the start of new row/column?
607 if ( i
&& (i
% m_majorDim
== 0) )
609 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
611 // start of new column
613 x_offset
+= maxWidth
+ cx1
;
615 else // start of new row
618 y_offset
+= maxHeight
;
619 if (m_radioWidth
[0]>0)
625 if ( isLastInTheRow
)
627 // make the button go to the end of radio box
628 widthBtn
= startX
+ width
- x_offset
- 2*cx1
;
629 if ( widthBtn
< maxWidth
)
634 // normal button, always of the same size
638 // VZ: make all buttons of the same, maximal size - like this they
639 // cover the radiobox entirely and the radiobox tooltips are always
640 // shown (otherwise they are not when the mouse pointer is in the
641 // radiobox part not belonging to any radiobutton)
642 ::MoveWindow((HWND
)m_radioButtons
[i
],
643 x_offset
, y_offset
, widthBtn
, maxHeight
,
646 // where do we put the next button?
647 if ( m_windowStyle
& wxRA_SPECIFY_ROWS
)
650 y_offset
+= maxHeight
;
651 if (m_radioWidth
[0]>0)
656 // to the right of this one
657 x_offset
+= widthBtn
+ cx1
;
662 void wxRadioBox
::GetSize(int *width
, int *height
) const
664 RECT rect
= { -1, -1, -1, -1 };
667 wxFindMaxSize(m_hWnd
, &rect
);
670 for (i
= 0; i
< m_noItems
; i
++)
671 wxFindMaxSize(m_radioButtons
[i
], &rect
);
673 *width
= rect
.right
- rect
.left
;
674 *height
= rect
.bottom
- rect
.top
;
677 void wxRadioBox
::GetPosition(int *x
, int *y
) const
679 wxWindow
*parent
= GetParent();
680 RECT rect
= { -1, -1, -1, -1 };
683 for (i
= 0; i
< m_noItems
; i
++)
684 wxFindMaxSize(m_radioButtons
[i
], &rect
);
687 wxFindMaxSize(m_hWnd
, &rect
);
689 // Since we now have the absolute screen coords, if there's a parent we
690 // must subtract its top left corner
696 ::ScreenToClient((HWND
) parent
->GetHWND(), &point
);
699 // We may be faking the client origin. So a window that's really at (0, 30)
700 // may appear (to wxWin apps) to be at (0, 0).
703 wxPoint
pt(GetParent()->GetClientAreaOrigin());
712 void wxRadioBox
::SetFocus()
716 ::SetFocus((HWND
)m_radioButtons
[m_selectedButton
== wxID_ANY
718 : m_selectedButton
]);
723 bool wxRadioBox
::Show(bool show
)
725 if ( !wxControl
::Show(show
) )
728 int nCmdShow
= show ? SW_SHOW
: SW_HIDE
;
729 for ( int i
= 0; i
< m_noItems
; i
++ )
731 ::ShowWindow((HWND
)m_radioButtons
[i
], nCmdShow
);
737 // Enable a specific button
738 void wxRadioBox
::Enable(int item
, bool enable
)
740 wxCHECK_RET( item
>= 0 && item
< m_noItems
,
741 wxT("invalid item in wxRadioBox::Enable()") );
743 ::EnableWindow((HWND
) m_radioButtons
[item
], enable
);
746 // Enable all controls
747 bool wxRadioBox
::Enable(bool enable
)
749 if ( !wxControl
::Enable(enable
) )
752 for (int i
= 0; i
< m_noItems
; i
++)
753 ::EnableWindow((HWND
) m_radioButtons
[i
], enable
);
758 // Show a specific button
759 void wxRadioBox
::Show(int item
, bool show
)
761 wxCHECK_RET( item
>= 0 && item
< m_noItems
,
762 wxT("invalid item in wxRadioBox::Show()") );
764 ::ShowWindow((HWND
)m_radioButtons
[item
], show ? SW_SHOW
: SW_HIDE
);
767 bool wxRadioBox
::ContainsHWND(WXHWND hWnd
) const
769 size_t count
= GetCount();
770 for ( size_t i
= 0; i
< count
; i
++ )
772 if ( GetRadioButtons()[i
] == hWnd
)
779 void wxRadioBox
::Command(wxCommandEvent
& event
)
781 SetSelection (event
.m_commandInt
);
783 ProcessCommand (event
);
786 // NB: if this code is changed, wxGetWindowForHWND() which relies on having the
787 // radiobox pointer in GWL_USERDATA for radio buttons must be updated too!
788 void wxRadioBox
::SubclassRadioButton(WXHWND hWndBtn
)
790 HWND hwndBtn
= (HWND
)hWndBtn
;
792 if ( !s_wndprocRadioBtn
)
793 s_wndprocRadioBtn
= (WXFARPROC
)wxGetWindowProc(hwndBtn
);
795 wxSetWindowProc(hwndBtn
, wxRadioBtnWndProc
);
796 wxSetWindowUserData(hwndBtn
, this);
799 void wxRadioBox
::SendNotificationEvent()
801 wxCommandEvent
event(wxEVT_COMMAND_RADIOBOX_SELECTED
, m_windowId
);
802 event
.SetInt( m_selectedButton
);
803 event
.SetString( GetString(m_selectedButton
) );
804 event
.SetEventObject( this );
805 ProcessCommand(event
);
808 bool wxRadioBox
::SetFont(const wxFont
& font
)
810 if ( !wxControl
::SetFont(font
) )
816 // also set the font of our radio buttons
817 WXHFONT hfont
= wxFont(font
).GetResourceHandle();
818 for ( int n
= 0; n
< m_noItems
; n
++ )
820 HWND hwndBtn
= (HWND
)m_radioButtons
[n
];
821 ::SendMessage(hwndBtn
, WM_SETFONT
, (WPARAM
)hfont
, 0L);
823 // otherwise the buttons are not redrawn correctly
824 ::InvalidateRect(hwndBtn
, NULL
, FALSE
/* don't erase bg */);
830 // ----------------------------------------------------------------------------
832 // ----------------------------------------------------------------------------
834 WXLRESULT wxRadioBox
::MSWWindowProc(WXUINT nMsg
, WXWPARAM wParam
, WXLPARAM lParam
)
836 #if RADIOBTN_PARENT_IS_RADIOBOX
839 // handle this message to set correct colours for our buttons here
840 case WM_CTLCOLORSTATIC
:
844 UnpackCtlColor(wParam
, lParam
, &hdc
, &hwnd
);
846 WXHBRUSH hbr
= MSWControlColor((WXHDC
)hdc
);
848 return (WXLRESULT
)hbr
;
849 //else: fall through to default window proc
852 #endif // RADIOBTN_PARENT_IS_RADIOBOX
854 return wxControl
::MSWWindowProc(nMsg
, wParam
, lParam
);
857 // ---------------------------------------------------------------------------
858 // window proc for radio buttons
859 // ---------------------------------------------------------------------------
863 LRESULT APIENTRY _EXPORT
wxRadioBtnWndProc(HWND hwnd
,
871 // we must tell IsDialogMessage()/our kbd processing code that we
872 // want to process arrows ourselves because neither of them is
873 // smart enough to handle arrows properly for us
875 long lDlgCode
= ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
,
876 message
, wParam
, lParam
);
878 return lDlgCode
| DLGC_WANTARROWS
;
884 NMHDR
* hdr
= (NMHDR
*)lParam
;
885 if ( hdr
->code
== TTN_NEEDTEXT
)
888 radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
890 wxCHECK_MSG( radiobox
, 0,
891 wxT("radio button without radio box?") );
893 wxToolTip
*tooltip
= radiobox
->GetToolTip();
896 TOOLTIPTEXT
*ttt
= (TOOLTIPTEXT
*)lParam
;
897 ttt
->lpszText
= (wxChar
*)tooltip
->GetTip().c_str();
905 #endif // wxUSE_TOOLTIPS
909 wxRadioBox
*radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
911 wxCHECK_MSG( radiobox
, 0, wxT("radio button without radio box?") );
913 bool processed
= true;
937 // just to suppress the compiler warning
943 int selOld
= radiobox
->GetSelection();
944 int selNew
= radiobox
->GetNextItem
948 radiobox
->GetWindowStyle()
951 if ( selNew
!= selOld
)
953 radiobox
->SetSelection(selNew
);
954 radiobox
->SetFocus();
956 // emulate the button click
957 radiobox
->SendNotificationEvent();
968 wxRadioBox
*radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
970 wxCHECK_MSG( radiobox
, 0, wxT("radio button without radio box?") );
972 // if we don't do this, no focus events are generated for the
973 // radiobox and, besides, we need to notify the parent about
974 // the focus change, otherwise the focus handling logic in
975 // wxControlContainer doesn't work
976 if ( message
== WM_SETFOCUS
)
977 radiobox
->HandleSetFocus((WXHWND
)wParam
);
979 radiobox
->HandleKillFocus((WXHWND
)wParam
);
986 wxRadioBox
*radiobox
= (wxRadioBox
*)wxGetWindowUserData(hwnd
);
988 wxCHECK_MSG( radiobox
, 0, wxT("radio button without radio box?") );
990 bool processed
wxDUMMY_INITIALIZE(true);
992 // HELPINFO doesn't seem to be supported on WinCE.
994 HELPINFO
* info
= (HELPINFO
*) lParam
;
995 // Don't yet process menu help events, just windows
996 if (info
->iContextType
== HELPINFO_WINDOW
)
999 wxWindow
* subjectOfHelp
= radiobox
;
1000 bool eventProcessed
= false;
1001 while (subjectOfHelp
&& !eventProcessed
)
1003 wxHelpEvent
helpEvent(wxEVT_HELP
, subjectOfHelp
->GetId(),
1007 wxPoint(info
->MousePos
.x
, info
->MousePos
.y
)
1009 ) ; // info->iCtrlId);
1010 helpEvent
.SetEventObject(radiobox
);
1011 eventProcessed
= radiobox
->GetEventHandler()->ProcessEvent(helpEvent
);
1013 // Go up the window hierarchy until the event is handled (or not)
1014 subjectOfHelp
= subjectOfHelp
->GetParent();
1016 processed
= eventProcessed
;
1019 else if (info
->iContextType
== HELPINFO_MENUITEM
)
1021 wxHelpEvent
helpEvent(wxEVT_HELP
, info
->iCtrlId
) ;
1022 helpEvent
.SetEventObject(radiobox
);
1023 processed
= radiobox
->GetEventHandler()->ProcessEvent(helpEvent
);
1036 return ::CallWindowProc(CASTWNDPROC s_wndprocRadioBtn
, hwnd
, message
, wParam
, lParam
);
1041 #endif // wxUSE_RADIOBOX