1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  18     #include "wx/wxchar.h" 
  19     #include "wx/string.h" 
  20     #include "wx/bitmap.h" 
  22     #include "wx/radiobox.h" 
  25 #include "wx/os2/private.h" 
  27 IMPLEMENT_DYNAMIC_CLASS(wxRadioBox
, wxControl
) 
  29 // --------------------------------------------------------------------------- 
  31 // --------------------------------------------------------------------------- 
  33 // wnd proc for radio buttons 
  34 MRESULT EXPENTRY 
wxRadioBtnWndProc( HWND hWnd
 
  39 MRESULT EXPENTRY 
wxRadioBoxWndProc( HWND   hWnd
 
  45 // --------------------------------------------------------------------------- 
  47 // --------------------------------------------------------------------------- 
  49 // the pointer to standard radio button wnd proc 
  50 extern void  wxAssociateWinWithHandle( HWND         hWnd
 
  53 static WXFARPROC                    fnWndProcRadioBtn 
= NULL
; 
  54 static WXFARPROC                    fnWndProcRadioBox 
= NULL
; 
  56 // =========================================================================== 
  58 // =========================================================================== 
  60 // --------------------------------------------------------------------------- 
  62 // --------------------------------------------------------------------------- 
  65 wxRadioBox::wxRadioBox() 
  67     m_nSelectedButton 
= -1; 
  70     m_ahRadioButtons 
= NULL
; 
  72     m_pnRadioWidth 
= NULL
; 
  73     m_pnRadioHeight 
= NULL
; 
  74 } // end of wxRadioBox::wxRadioBox 
  76 wxRadioBox::~wxRadioBox() 
  78     m_isBeingDeleted 
= TRUE
; 
  83         for (i 
= 0; i 
< m_nNoItems
; i
++) 
  84             ::WinDestroyWindow((HWND
)m_ahRadioButtons
[i
]); 
  85         delete[] m_ahRadioButtons
; 
  88         delete[] m_pnRadioWidth
; 
  90         delete[] m_pnRadioHeight
; 
  91 } // end of wxRadioBox::~wxRadioBox 
  93 void wxRadioBox::AdjustButtons( 
 103     int                             nYOffset 
= nY 
+ nHeight
; 
 110     wxFont                          vFont 
= GetFont(); 
 112     wxGetCharSize( m_hWnd
 
 117     vMaxSize   
= GetMaxButtonSize(); 
 118     nMaxWidth  
= vMaxSize
.x
; 
 119     nMaxHeight 
= vMaxSize
.y
; 
 122     nYOffset 
-= (nMaxHeight 
+ ((3*nCy1
)/2)); 
 127     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 130         // The last button in the row may be wider than the other ones as the 
 131         // radiobox may be wider than the sum of the button widths (as it 
 132         // happens, for example, when the radiobox label is very long) 
 134         bool                        bIsLastInTheRow
; 
 136         if (m_windowStyle 
& wxRA_SPECIFY_COLS
) 
 139             // Item is the last in its row if it is a multiple of the number of 
 140             // columns or if it is just the last item 
 144             bIsLastInTheRow 
= ((n 
% m_nMajorDim
) == 0) || (n 
== m_nNoItems
); 
 146         else // winRA_SPECIFY_ROWS 
 149             // Item is the last in the row if it is in the last columns 
 151             bIsLastInTheRow 
= i 
>= (m_nNoItems
/m_nMajorDim
) * m_nMajorDim
; 
 155         // Is this the start of new row/column? 
 157         if (i 
&& (i 
% m_nMajorDim 
== 0)) 
 159             if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 163                 // Start of new column 
 166                 nXOffset 
+= nMaxWidth 
+ nCx1
; 
 168             else // start of new row 
 171                 nYOffset 
-= nMaxHeight
; 
 172                 if (m_pnRadioWidth
[0] > 0L) 
 182             // Make the button go to the end of radio box 
 184             nWidthBtn 
= nStartX 
+ nWidth 
- nXOffset 
- (2 * nCx1
); 
 185             if (nWidthBtn 
< nMaxWidth
) 
 186                 nWidthBtn 
= nMaxWidth
; 
 191             // Normal button, always of the same size 
 193             nWidthBtn 
= nMaxWidth
; 
 197         // Make all buttons of the same, maximal size - like this they 
 198         // cover the radiobox entirely and the radiobox tooltips are always 
 199         // shown (otherwise they are not when the mouse pointer is in the 
 200         // radiobox part not beYInt32ing to any radiobutton) 
 202         ::WinSetWindowPos( (HWND
)m_ahRadioButtons
[i
] 
 208                           ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 211         // Where do we put the next button? 
 213         if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 218             nYOffset 
-= nMaxHeight
; 
 219             if (m_pnRadioWidth
[0] > 0) 
 225             // To the right of this one 
 227             nXOffset 
+= nWidthBtn 
+ nCx1
; 
 230 } // end of wxRadioBox::AdjustButtons 
 232 void wxRadioBox::Command ( 
 233   wxCommandEvent
&                   rEvent
 
 236     SetSelection (rEvent
.GetInt()); 
 237     ProcessCommand(rEvent
); 
 238 } // end of wxRadioBox::Command 
 240 bool wxRadioBox::ContainsHWND( 
 244     size_t                          nCount 
= GetCount(); 
 247     for (i 
= 0; i 
< nCount
; i
++) 
 249         if (GetRadioButtons()[i
] == hWnd
) 
 253 } // end of wxRadioBox::ContainsHWND 
 255 bool wxRadioBox::Create( 
 258 , const wxString
&                   rsTitle
 
 259 , const wxPoint
&                    rPos
 
 260 , const wxSize
&                     rSize
 
 261 , const wxArrayString
&              asChoices
 
 264 , const wxValidator
&                rVal
 
 265 , const wxString
&                   rsName
 
 268     wxCArrayString 
chs(asChoices
); 
 270     return Create(pParent
, vId
, rsTitle
, rPos
, rSize
, chs
.GetCount(), 
 271                   chs
.GetStrings(), nMajorDim
, lStyle
, rVal
, rsName
); 
 274 bool wxRadioBox::Create( 
 277 , const wxString
&                   rsTitle
 
 278 , const wxPoint
&                    rPos
 
 279 , const wxSize
&                     rSize
 
 281 , const wxString                    asChoices
[] 
 284 , const wxValidator
&                rVal
 
 285 , const wxString
&                   rsName
 
 291     vColour
.Set(wxString("BLACK")); 
 292     m_backgroundColour 
= pParent
->GetBackgroundColour(); 
 293     m_nSelectedButton 
= -1; 
 296     m_nMajorDim     
= nMajorDim 
== 0 ? nNum 
: nMajorDim
; 
 297     m_nNoRowsOrCols 
= nMajorDim
; 
 300     // Common initialization 
 302     if (!CreateControl( pParent
 
 311     if (!OS2CreateControl( "STATIC" 
 319     wxAssociateWinWithHandle(m_hWnd
, this); 
 322     // Some radio boxes test consecutive id. 
 325     (void)NewControlId(); 
 326     m_ahRadioButtons 
= new WXHWND
[nNum
]; 
 327     m_pnRadioWidth   
= new int[nNum
]; 
 328     m_pnRadioHeight  
= new int[nNum
]; 
 330     for (int i 
= 0; i 
< nNum
; i
++) 
 332         m_pnRadioWidth
[i
] = m_pnRadioHeight
[i
] = -1; 
 334         long                        lStyleBtn 
= BS_AUTORADIOBUTTON 
| WS_TABSTOP 
| WS_VISIBLE
; 
 335         int                         nNewId 
= NewControlId(); 
 337         if (i 
== 0 && lStyle 
== 0) 
 338             lStyleBtn 
|= WS_GROUP
; 
 340         HWND                        hWndBtn 
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
) 
 351         lColor 
= (LONG
)vColour
.GetPixel(); 
 352         ::WinSetPresParam( hWndBtn
 
 357         lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 359         ::WinSetPresParam( hWndBtn
 
 368         m_ahRadioButtons
[i
] = (WXHWND
)hWndBtn
; 
 369         SubclassRadioButton((WXHWND
)hWndBtn
); 
 370         wxAssociateWinWithHandle(hWndBtn
, this); 
 371         wxOS2SetFont( hWndBtn
 
 374         ::WinSetWindowULong(hWndBtn
, QWL_USER
, (ULONG
)this); 
 375         m_aSubControls
.Add(nNewId
); 
 379     // Create a dummy radio control to end the group. 
 381     (void)::WinCreateWindow ( GetHwndOf(pParent
) 
 384                              ,WS_GROUP 
| BS_AUTORADIOBUTTON
 
 388                              ,(HMENU
)NewControlId() 
 392     SetFont(*wxSMALL_FONT
); 
 393     fnWndProcRadioBox 
= (WXFARPROC
)::WinSubclassWindow( GetHwnd() 
 394                                                        ,(PFNWP
)wxRadioBoxWndProc
 
 396     ::WinSetWindowULong(GetHwnd(), QWL_USER
, (ULONG
)this); 
 397     lColor 
= (LONG
)vColour
.GetPixel(); 
 398     ::WinSetPresParam( m_hWnd
 
 403     ::WinSetPresParam( m_hWnd
 
 408     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 410     ::WinSetPresParam( m_hWnd
 
 415     ::WinSetPresParam( m_hWnd
 
 429 } // end of wxRadioBox::Create 
 431 wxSize 
wxRadioBox::DoGetBestSize() const 
 433     return (GetTotalButtonSize(GetMaxButtonSize())); 
 434 } // end of WinGuiBase_CRadioBox::DoGetBestSize 
 436 void wxRadioBox::DoSetSize( 
 450 #if RADIOBTN_PARENT_IS_RADIOBOX 
 459     wxSize                          vMaxSize 
= GetMaxButtonSize(); 
 467     wxFont                          vFont 
= GetFont(); 
 469     m_nSizeFlags 
= nSizeFlags
; 
 470     GetPosition( &nCurrentX
 
 477     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 479     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 486     wxGetCharSize( m_hWnd
 
 493     // Attempt to have a look coherent with other platforms: We compute the 
 494     // biggest toggle dim, then we align all items according this value. 
 496     vMaxSize   
= GetMaxButtonSize(); 
 497     nMaxWidth  
= vMaxSize
.x
; 
 498     nMaxHeight 
= vMaxSize
.y
; 
 500     vTotSize   
= GetTotalButtonSize(vMaxSize
); 
 501     nTotWidth  
= vTotSize
.x
; 
 502     nTotHeight 
= vTotSize
.y
; 
 505     // Only change our width/height if asked for 
 509         if (nSizeFlags 
& wxSIZE_AUTO_WIDTH 
) 
 517         if (nSizeFlags 
& wxSIZE_AUTO_HEIGHT
) 
 518             nHeight 
= nTotHeight
; 
 520             nHeight 
= nHeightOld
; 
 523     wxWindowOS2
*                    pParent 
= (wxWindowOS2
*)GetParent(); 
 527         int                         nOS2Height 
= GetOS2ParentHeight(pParent
); 
 529         nYy 
= nOS2Height 
- (nYy 
+ nHeight
); 
 530         nYOffset 
= nYy 
+ nHeight
; 
 536         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 537         nYy 
= vRect
.yTop 
- (nYy 
+ nHeight
); 
 539     ::WinSetWindowPos( GetHwnd() 
 545                       ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 549     // Now position all the buttons: the current button will be put at 
 550     // wxPoint(x_offset, y_offset) and the new row/column will start at 
 551     // startX/startY. The size of all buttons will be the same wxSize(maxWidth, 
 552     // maxHeight) except for the buttons in the last column which should extend 
 553     // to the right border of radiobox and thus can be wider than this. 
 555     // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in 
 556     // left to right order and m_majorDim is the number of columns while 
 557     // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and 
 558     // m_majorDim is the number of rows. 
 561     nYOffset 
-= (nMaxHeight 
+ ((3*nCy1
)/2)); 
 566     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 569         // The last button in the row may be wider than the other ones as the 
 570         // radiobox may be wider than the sum of the button widths (as it 
 571         // happens, for example, when the radiobox label is very long) 
 573         bool                        bIsLastInTheRow
; 
 575         if (m_windowStyle 
& wxRA_SPECIFY_COLS
) 
 578             // Item is the last in its row if it is a multiple of the number of 
 579             // columns or if it is just the last item 
 583             bIsLastInTheRow 
= ((n 
% m_nMajorDim
) == 0) || (n 
== m_nNoItems
); 
 585         else // winRA_SPECIFY_ROWS 
 588             // Item is the last in the row if it is in the last columns 
 590             bIsLastInTheRow 
= i 
>= (m_nNoItems
/m_nMajorDim
) * m_nMajorDim
; 
 594         // Is this the start of new row/column? 
 596         if (i 
&& (i 
% m_nMajorDim 
== 0)) 
 598             if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 602                 // Start of new column 
 605                 nXOffset 
+= nMaxWidth 
+ nCx1
; 
 607             else // start of new row 
 610                 nYOffset 
-= nMaxHeight
; 
 611                 if (m_pnRadioWidth
[0] > 0L) 
 621             // Make the button go to the end of radio box 
 623             nWidthBtn 
= nStartX 
+ nWidth 
- nXOffset 
- (2 * nCx1
); 
 624             if (nWidthBtn 
< nMaxWidth
) 
 625                 nWidthBtn 
= nMaxWidth
; 
 630             // Normal button, always of the same size 
 632             nWidthBtn 
= nMaxWidth
; 
 636         // Make all buttons of the same, maximal size - like this they 
 637         // cover the radiobox entirely and the radiobox tooltips are always 
 638         // shown (otherwise they are not when the mouse pointer is in the 
 639         // radiobox part not beinting to any radiobutton) 
 641         ::WinSetWindowPos( (HWND
)m_ahRadioButtons
[i
] 
 647                           ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 649         GetParent()->Refresh(); 
 651         // Where do we put the next button? 
 653         if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 658             nYOffset 
-= nMaxHeight
; 
 659             if (m_pnRadioWidth
[0] > 0) 
 665             // To the right of this one 
 667             nXOffset 
+= nWidthBtn 
+ nCx1
; 
 670 } // end of wxRadioBox::DoSetSize 
 672 void wxRadioBox::Enable( 
 677     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, 
 678                  wxT("invalid item in wxRadioBox::Enable()") ); 
 680     ::WinEnableWindow((HWND
) m_ahRadioButtons
[nItem
], bEnable
); 
 681 } // end of wxRadioBox::Enable 
 683 bool wxRadioBox::Enable( 
 687     if ( !wxControl::Enable(bEnable
) ) 
 689     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 690         ::WinEnableWindow((HWND
)m_ahRadioButtons
[i
], bEnable
); 
 692 } // end of wxRadioBox::Enable 
 694 int wxRadioBox::FindString( 
 695   const wxString
&                   rsStr
 
 698     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 700         if (rsStr 
== wxGetWindowText(m_ahRadioButtons
[i
]) ) 
 704 } // end of wxRadioBox::FindString 
 706 int wxRadioBox::GetColumnCount() const 
 709 } // end of wxRadioBox::GetColumnCount 
 711 int wxRadioBox::GetCount() const 
 714 } // end of wxRadioBox::GetCount 
 716 wxString 
wxRadioBox::GetLabel( 
 720     wxCHECK_MSG(nItem 
>= 0 && nItem 
< m_nNoItems
, wxT(""), wxT("invalid radiobox index") ); 
 722     return wxGetWindowText(m_ahRadioButtons
[nItem
]); 
 723 } // end of wxRadioBox::GetLabel 
 725 wxSize 
wxRadioBox::GetMaxButtonSize() const 
 730     for (int i 
= 0 ; i 
< m_nNoItems
; i
++) 
 735         if (m_pnRadioWidth
[i
] < 0L) 
 737             GetTextExtent( wxGetWindowText(m_ahRadioButtons
[i
]) 
 743             // Adjust the size to take into account the radio box itself 
 744             // FIXME this is totally bogus! 
 746             nWidth  
+= RADIO_SIZE
; 
 752             nWidth  
= m_pnRadioWidth
[i
]; 
 753             nHeight 
= m_pnRadioHeight
[i
]; 
 755         if (nWidthMax 
< nWidth 
) 
 757         if (nHeightMax 
< nHeight 
) 
 758             nHeightMax 
= nHeight
; 
 760     return(wxSize( nWidthMax
 
 764 } // end of wxRadioBox::GetMaxButtonSize 
 766 int wxRadioBox::GetNumHor() const 
 768     if ( m_windowStyle 
& wxRA_SPECIFY_ROWS 
) 
 770         return (m_nNoItems 
+ m_nMajorDim 
- 1)/m_nMajorDim
; 
 776 } // end of wxRadioBox::GetNumHor 
 778 int wxRadioBox::GetNumVer() const 
 780     if ( m_windowStyle 
& wxRA_SPECIFY_ROWS 
) 
 786         return (m_nNoItems 
+ m_nMajorDim 
- 1)/m_nMajorDim
; 
 788 } // end of wxRadioBox::GetNumVer 
 790 void wxRadioBox::GetPosition( 
 795     wxWindowOS2
*                    pParent 
= GetParent(); 
 796     RECT                            vRect 
= { -1, -1, -1, -1 };; 
 800     for (i 
= 0; i 
< m_nNoItems
; i
++) 
 801         wxFindMaxSize( m_ahRadioButtons
[i
] 
 805         wxFindMaxSize( m_hWnd
 
 810     // Since we now have the absolute screen coords, if there's a parent we 
 811     // must subtract its top left corner 
 813     vPoint
.x 
= vRect
.xLeft
; 
 814     vPoint
.y 
= vRect
.yTop
; 
 819         ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
); 
 825     // We may be faking the client origin. So a window that's really at (0, 30) 
 826     // may appear (to wxWin apps) to be at (0, 0). 
 830         wxPoint                     
vPt(GetParent()->GetClientAreaOrigin()); 
 837 } // end of wxRadioBox::GetPosition 
 839 int wxRadioBox::GetRowCount() const 
 842 } // end of wxRadioBox::GetRowCount 
 844 // Get single selection, for single choice list items 
 845 int wxRadioBox::GetSelection() const 
 847     return m_nSelectedButton
; 
 848 } // end of wxRadioBox::GetSelection 
 850 void wxRadioBox::GetSize( 
 864         wxFindMaxSize( m_hWnd
 
 868     for (i 
= 0; i 
< m_nNoItems
; i
++) 
 869         wxFindMaxSize( m_ahRadioButtons
[i
] 
 874         *pnWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
 876         *pnHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 877 } // end of wxRadioBox::GetSize 
 879 // Find string for position 
 880 wxString 
wxRadioBox::GetString( 
 884     return wxGetWindowText(m_ahRadioButtons
[nNum
]); 
 885 } // end of wxRadioBox::GetString 
 887 // For single selection items only 
 888 wxString 
wxRadioBox::GetStringSelection() const 
 891     int                             nSel 
= GetSelection(); 
 894         sResult 
= GetString(nSel
); 
 896 } // end of wxRadioBox::GetStringSelection 
 898 wxSize 
wxRadioBox::GetTotalButtonSize( 
 899   const wxSize
&                     rSizeBtn
 
 908     wxFont                          vFont 
= GetFont(); 
 910     wxGetCharSize( m_hWnd
 
 917     nHeight 
= GetNumVer() * rSizeBtn
.y 
+ (2 * nCy1
); 
 918     nWidth  
= GetNumHor() * (rSizeBtn
.x 
+ nCx1
) + nCx1
; 
 921     // And also wide enough for its label 
 923     GetTextExtent( GetTitle() 
 927     nWidthLabel 
+= RADIO_SIZE
; 
 928     if (nWidthLabel 
> nWidth
) 
 929         nWidth 
= nWidthLabel
; 
 931     return(wxSize( nWidth
 
 935 } // end of wxRadioBox::GetTotalButtonSize 
 937 WXHBRUSH 
wxRadioBox::OnCtlColor( 
 946     HPS                             hPS 
= (HPS
)hwinDC
; // pass in a PS handle in OS/2 
 948     if (GetParent()->GetTransparentBackground()) 
 949         ::GpiSetBackMix(hPS
, BM_LEAVEALONE
); 
 951         ::GpiSetBackMix(hPS
, BM_OVERPAINT
); 
 953     wxColour                        vColBack 
= GetBackgroundColour(); 
 955     ::GpiSetBackColor(hPS
, vColBack
.GetPixel()); 
 956     ::GpiSetColor(hPS
, vColBack
.GetPixel()); 
 959     wxBrush
*                        pBrush 
= wxTheBrushList
->FindOrCreateBrush( vColBack
 
 962     return ((WXHBRUSH
)pBrush
->GetResourceHandle()); 
 963 } // end of wxRadioBox::OnCtlColor 
 965 bool wxRadioBox::OS2Command( 
 970     int                             nSelectedButton 
= -1; 
 972     if (uCmd 
== BN_CLICKED
) 
 978         for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 980             if (wId 
== wxGetWindowId(m_ahRadioButtons
[i
])) 
 986         if (nSelectedButton 
== -1) 
 993         if (nSelectedButton 
!= m_nSelectedButton
) 
 995             m_nSelectedButton 
= nSelectedButton
; 
 996             SendNotificationEvent(); 
1002 } // end of wxRadioBox::OS2Command 
1004 void wxRadioBox::SendNotificationEvent() 
1006     wxCommandEvent                  
vEvent( wxEVT_COMMAND_RADIOBOX_SELECTED
 
1010     vEvent
.SetInt( m_nSelectedButton 
); 
1011     vEvent
.SetString( GetString(m_nSelectedButton
) ); 
1012     vEvent
.SetEventObject(this); 
1013     ProcessCommand(vEvent
); 
1014 } // end of wxRadioBox::SendNotificationEvent 
1016 void wxRadioBox::SetFocus() 
1020         if (m_nSelectedButton 
== -1) 
1021             ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[0]); 
1023             ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[m_nSelectedButton
]); 
1025 } // end of wxRadioBox::SetFocus 
1027 bool wxRadioBox::SetFont( 
1031     if (!wxControl::SetFont(rFont
)) 
1039     // Also set the font of our radio buttons 
1041     for (int n 
= 0; n 
< (int)m_nNoItems
; n
++) 
1043         HWND                        hWndBtn 
= (HWND
)m_ahRadioButtons
[n
]; 
1045         wxOS2SetFont( hWndBtn
 
1048         ::WinInvalidateRect(hWndBtn
, NULL
, FALSE
); 
1051 } // end of wxRadioBox::SetFont 
1053 void wxRadioBox::SetSelection( 
1057     wxCHECK_RET( (nNum 
>= 0) && (nNum 
< m_nNoItems
), wxT("invalid radiobox index") ); 
1059     if (m_nSelectedButton 
>= 0 && m_nSelectedButton 
< m_nNoItems
) 
1060         ::WinSendMsg((HWND
)m_ahRadioButtons
[m_nSelectedButton
], BM_SETCHECK
, (MPARAM
)0, (MPARAM
)0); 
1062     ::WinSendMsg((HWND
)m_ahRadioButtons
[nNum
], BM_SETCHECK
, (MPARAM
)1, (MPARAM
)0); 
1063     ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[nNum
]); 
1064     m_nSelectedButton 
= nNum
; 
1065 } // end of wxRadioBox::SetSelection 
1067 void wxRadioBox::SetString( 
1069 , const wxString
&                   rsLabel
 
1072     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, wxT("invalid radiobox index") ); 
1074     m_pnRadioWidth
[nItem
] = m_pnRadioHeight
[nItem
] = -1; 
1075     ::WinSetWindowText((HWND
)m_ahRadioButtons
[nItem
], rsLabel
.c_str()); 
1076 } // end of wxRadioBox::SetString 
1078 bool wxRadioBox::SetStringSelection( 
1079   const wxString
&                   rsStr
 
1082     int                             nSel 
= FindString(rsStr
); 
1091 } // end of wxRadioBox::SetStringSelection 
1093 bool wxRadioBox::Show( 
1097     if (!wxControl::Show(bShow
)) 
1100     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
1102         ::WinShowWindow((HWND
)m_ahRadioButtons
[i
], (BOOL
)bShow
); 
1105 } // end of wxRadioBox::Show 
1107 // Show a specific button 
1108 void wxRadioBox::Show( 
1113     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, 
1114                  wxT("invalid item in wxRadioBox::Show()") ); 
1116     ::WinShowWindow((HWND
)m_ahRadioButtons
[nItem
], bShow
); 
1117 } // end of wxRadioBox::Show 
1119 void wxRadioBox::SubclassRadioButton( 
1123     fnWndProcRadioBtn 
= (WXFARPROC
)::WinSubclassWindow(hWndBtn
, (PFNWP
)wxRadioBtnWndProc
); 
1124 } // end of wxRadioBox::SubclassRadioButton 
1126 MRESULT 
wxRadioBox::WindowProc( 
1132     return (wxControl::OS2WindowProc( uMsg
 
1136 } // end of wxRadioBox::WindowProc 
1138 // --------------------------------------------------------------------------- 
1139 // window proc for radio buttons 
1140 // --------------------------------------------------------------------------- 
1142 MRESULT 
wxRadioBtnWndProc( 
1153                 USHORT                  uKeyFlags 
= SHORT1FROMMP((MPARAM
)wParam
); 
1155                 if (!(uKeyFlags 
& KC_KEYUP
)) // Key Down event 
1157                     if (uKeyFlags 
& KC_VIRTUALKEY
) 
1159                         wxRadioBox
*             pRadiobox 
= (wxRadioBox 
*)::WinQueryWindowULong( hWnd
 
1162                         USHORT                  uVk 
= SHORT2FROMMP((MPARAM
)lParam
); 
1163                         bool                    bProcessed 
= TRUE
; 
1188                                 // Just to suppress the compiler warning 
1195                             int             nSelOld 
= pRadiobox
->GetSelection(); 
1196                             int             nSelNew 
= pRadiobox
->GetNextItem( nSelOld
 
1198                                                                              ,pRadiobox
->GetWindowStyleFlag() 
1201                             if (nSelNew 
!= nSelOld
) 
1203                                 pRadiobox
->SetSelection(nSelNew
); 
1206                                 // Emulate the button click 
1208                                 pRadiobox
->SendNotificationEvent(); 
1218     return fnWndProcRadioBtn( hWnd
 
1223 } // end of wxRadioBtnWndProc 
1225 MRESULT EXPENTRY 
wxRadioBoxWndProc( 
1232     return (fnWndProcRadioBox( hWnd
 
1238 } // end of wxRadioBoxWndProc