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
 
  40 // --------------------------------------------------------------------------- 
  42 // --------------------------------------------------------------------------- 
  44 // the pointer to standard radio button wnd proc 
  45 static WXFARPROC                    fnWndProcRadioBtn 
= NULL
; 
  47 // =========================================================================== 
  49 // =========================================================================== 
  51 // --------------------------------------------------------------------------- 
  53 // --------------------------------------------------------------------------- 
  56 wxRadioBox::wxRadioBox() 
  58     m_nSelectedButton 
= -1; 
  61     m_ahRadioButtons 
= NULL
; 
  63     m_pnRadioWidth 
= NULL
; 
  64     m_pnRadioHeight 
= NULL
; 
  65 } // end of wxRadioBox::wxRadioBox 
  67 wxRadioBox::~wxRadioBox() 
  69     m_isBeingDeleted 
= TRUE
; 
  74         for (i 
= 0; i 
< m_nNoItems
; i
++) 
  75             ::WinDestroyWindow((HWND
)m_ahRadioButtons
[i
]); 
  76         delete[] m_ahRadioButtons
; 
  79         delete[] m_pnRadioWidth
; 
  81         delete[] m_pnRadioHeight
; 
  82 } // end of wxRadioBox::~wxRadioBox 
  84 void wxRadioBox::AdjustButtons( 
  94     int                             nYOffset 
= nY 
+ nHeight
; 
 104     wxGetCharSize( m_hWnd
 
 109     vMaxSize   
= GetMaxButtonSize(); 
 110     nMaxWidth  
= vMaxSize
.x
; 
 111     nMaxHeight 
= vMaxSize
.y
; 
 114     nYOffset 
-= (nMaxHeight 
+ ((3*nCy1
)/2)); 
 119     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 122         // The last button in the row may be wider than the other ones as the 
 123         // radiobox may be wider than the sum of the button widths (as it 
 124         // happens, for example, when the radiobox label is very long) 
 126         bool                        bIsLastInTheRow
; 
 128         if (m_windowStyle 
& wxRA_SPECIFY_COLS
) 
 131             // Item is the last in its row if it is a multiple of the number of 
 132             // columns or if it is just the last item 
 136             bIsLastInTheRow 
= ((n 
% m_nMajorDim
) == 0) || (n 
== m_nNoItems
); 
 138         else // winRA_SPECIFY_ROWS 
 141             // Item is the last in the row if it is in the last columns 
 143             bIsLastInTheRow 
= i 
>= (m_nNoItems
/m_nMajorDim
) * m_nMajorDim
; 
 147         // Is this the start of new row/column? 
 149         if (i 
&& (i 
% m_nMajorDim 
== 0)) 
 151             if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 155                 // Start of new column 
 158                 nXOffset 
+= nMaxWidth 
+ nCx1
; 
 160             else // start of new row 
 163                 nYOffset 
-= nMaxHeight
; 
 164                 if (m_pnRadioWidth
[0] > 0L) 
 174             // Make the button go to the end of radio box 
 176             nWidthBtn 
= nStartX 
+ nWidth 
- nXOffset 
- (2 * nCx1
); 
 177             if (nWidthBtn 
< nMaxWidth
) 
 178                 nWidthBtn 
= nMaxWidth
; 
 183             // Normal button, always of the same size 
 185             nWidthBtn 
= nMaxWidth
; 
 189         // Make all buttons of the same, maximal size - like this they 
 190         // cover the radiobox entirely and the radiobox tooltips are always 
 191         // shown (otherwise they are not when the mouse pointer is in the 
 192         // radiobox part not beYInt32ing to any radiobutton) 
 194         ::WinSetWindowPos( (HWND
)m_ahRadioButtons
[i
] 
 200                           ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 203         // Where do we put the next button? 
 205         if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 210             nYOffset 
-= nMaxHeight
; 
 211             if (m_pnRadioWidth
[0] > 0) 
 217             // To the right of this one 
 219             nXOffset 
+= nWidthBtn 
+ nCx1
; 
 222 } // end of wxRadioBox::AdjustButtons 
 224 void wxRadioBox::Command ( 
 225   wxCommandEvent
&                   rEvent
 
 228     SetSelection (rEvent
.GetInt()); 
 229     ProcessCommand(rEvent
); 
 230 } // end of wxRadioBox::Command 
 232 bool wxRadioBox::ContainsHWND( 
 236     size_t                          nCount 
= GetCount(); 
 239     for (i 
= 0; i 
< nCount
; i
++) 
 241         if (GetRadioButtons()[i
] == hWnd
) 
 245 } // end of wxRadioBox::ContainsHWND 
 247 bool wxRadioBox::Create( 
 250 , const wxString
&                   rsTitle
 
 251 , const wxPoint
&                    rPos
 
 252 , const wxSize
&                     rSize
 
 254 , const wxString                    asChoices
[] 
 258 , const wxValidator
&                rVal
 
 260 , const wxString
&                   rsName
 
 264     // System fonts are too big in OS/2 and they are blue 
 265     // We want smaller fonts and black by default. 
 267     wxFont
*                          pTextFont 
= new wxFont( 10 
 275     vColour
.Set(wxString("BLACK")); 
 276     lColor 
= (LONG
)vColour
.GetPixel(); 
 277     m_nSelectedButton 
= -1; 
 280     m_nMajorDim     
= nMajorDim 
== 0 ? nNum 
: nMajorDim
; 
 281     m_nNoRowsOrCols 
= nMajorDim
; 
 284     // Common initialization 
 286     if (!OS2CreateControl( pParent
 
 300     if (!OS2CreateControl( "STATIC" 
 301 #if RADIOBTN_PARENT_IS_RADIOBOX 
 302                           ,SS_GROUPBOX 
| WS_GROUP 
| WS_CLIPCHILDREN
 
 304                           ,SS_GROUPBOX 
| WS_GROUP 
| WS_CLIPSIBLINGS
 
 311 #if RADIOBTN_PARENT_IS_RADIOBOX 
 312     HWND                            hWndParent 
= GetHwnd(); 
 314     HWND                            hWndParent 
= GetHwndOf(pParent
); 
 319     // Some radio boxes test consecutive id. 
 321     (void)NewControlId(); 
 322     m_ahRadioButtons 
= new WXHWND
[nNum
]; 
 323     m_pnRadioWidth   
= new int[nNum
]; 
 324     m_pnRadioHeight  
= new int[nNum
]; 
 328         hFont 
= pTextFont
->GetResourceHandle(); 
 331     for (int i 
= 0; i 
< nNum
; i
++) 
 333         m_pnRadioWidth
[i
] = m_pnRadioHeight
[i
] = -1; 
 335         long                        lStyleBtn 
= BS_AUTORADIOBUTTON 
| WS_TABSTOP 
| WS_VISIBLE
; 
 336         int                         nNewId 
= NewControlId(); 
 338         if (i 
== 0 && lStyle 
== 0) 
 339             lStyleBtn 
|= WS_GROUP
; 
 341         HWND                        hWndBtn 
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
) 
 352         lColor 
= (LONG
)vColour
.GetPixel(); 
 353         ::WinSetPresParam( hWndBtn
 
 358         lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 360         ::WinSetPresParam( hWndBtn
 
 369         m_ahRadioButtons
[i
] = (WXHWND
)hWndBtn
; 
 370         SubclassRadioButton((WXHWND
)hWndBtn
); 
 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() 
 393     lColor 
= (LONG
)vColour
.GetPixel(); 
 394     ::WinSetPresParam( m_hWnd
 
 399     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 401     ::WinSetPresParam( m_hWnd
 
 414 } // end of wxRadioBox::Create 
 416 wxSize 
wxRadioBox::DoGetBestSize() const 
 418     return (GetTotalButtonSize(GetMaxButtonSize())); 
 419 } // end of WinGuiBase_CRadioBox::DoGetBestSize 
 421 void wxRadioBox::DoSetSize( 
 435 #if RADIOBTN_PARENT_IS_RADIOBOX 
 444     wxSize                          vMaxSize 
= GetMaxButtonSize(); 
 453     m_nSizeFlags 
= nSizeFlags
; 
 454     GetPosition( &nCurrentX
 
 461     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 463     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 467     wxGetCharSize( m_hWnd
 
 474     // Attempt to have a look coherent with other platforms: We compute the 
 475     // biggest toggle dim, then we align all items according this value. 
 477     vMaxSize   
= GetMaxButtonSize(); 
 478     nMaxWidth  
= vMaxSize
.x
; 
 479     nMaxHeight 
= vMaxSize
.y
; 
 481     vTotSize   
= GetTotalButtonSize(vMaxSize
); 
 482     nTotWidth  
= vTotSize
.x
; 
 483     nTotHeight 
= vTotSize
.y
; 
 486     // Only change our width/height if asked for 
 490         if (nSizeFlags 
& wxSIZE_AUTO_WIDTH 
) 
 498         if (nSizeFlags 
& wxSIZE_AUTO_HEIGHT
) 
 499             nHeight 
= nTotHeight
; 
 501             nHeight 
= nHeightOld
; 
 504     wxWindowOS2
*                    pParent 
= (wxWindowOS2
*)GetParent(); 
 508         int                         nOS2Height 
= GetOS2ParentHeight(pParent
); 
 510         nYy 
= nOS2Height 
- (nYy 
+ nHeight
); 
 511         nYOffset 
= nYy 
+ nHeight
; 
 517         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 518         nYy 
= vRect
.yTop 
- (nYy 
+ nHeight
); 
 520     ::WinSetWindowPos( GetHwnd() 
 526                       ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 530     // Now position all the buttons: the current button will be put at 
 531     // wxPoint(x_offset, y_offset) and the new row/column will start at 
 532     // startX/startY. The size of all buttons will be the same wxSize(maxWidth, 
 533     // maxHeight) except for the buttons in the last column which should extend 
 534     // to the right border of radiobox and thus can be wider than this. 
 536     // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in 
 537     // left to right order and m_majorDim is the number of columns while 
 538     // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and 
 539     // m_majorDim is the number of rows. 
 542     nYOffset 
-= (nMaxHeight 
+ ((3*nCy1
)/2)); 
 547     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 550         // The last button in the row may be wider than the other ones as the 
 551         // radiobox may be wider than the sum of the button widths (as it 
 552         // happens, for example, when the radiobox label is very long) 
 554         bool                        bIsLastInTheRow
; 
 556         if (m_windowStyle 
& wxRA_SPECIFY_COLS
) 
 559             // Item is the last in its row if it is a multiple of the number of 
 560             // columns or if it is just the last item 
 564             bIsLastInTheRow 
= ((n 
% m_nMajorDim
) == 0) || (n 
== m_nNoItems
); 
 566         else // winRA_SPECIFY_ROWS 
 569             // Item is the last in the row if it is in the last columns 
 571             bIsLastInTheRow 
= i 
>= (m_nNoItems
/m_nMajorDim
) * m_nMajorDim
; 
 575         // Is this the start of new row/column? 
 577         if (i 
&& (i 
% m_nMajorDim 
== 0)) 
 579             if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 583                 // Start of new column 
 586                 nXOffset 
+= nMaxWidth 
+ nCx1
; 
 588             else // start of new row 
 591                 nYOffset 
-= nMaxHeight
; 
 592                 if (m_pnRadioWidth
[0] > 0L) 
 602             // Make the button go to the end of radio box 
 604             nWidthBtn 
= nStartX 
+ nWidth 
- nXOffset 
- (2 * nCx1
); 
 605             if (nWidthBtn 
< nMaxWidth
) 
 606                 nWidthBtn 
= nMaxWidth
; 
 611             // Normal button, always of the same size 
 613             nWidthBtn 
= nMaxWidth
; 
 617         // Make all buttons of the same, maximal size - like this they 
 618         // cover the radiobox entirely and the radiobox tooltips are always 
 619         // shown (otherwise they are not when the mouse pointer is in the 
 620         // radiobox part not beinting to any radiobutton) 
 622         ::WinSetWindowPos( (HWND
)m_ahRadioButtons
[i
] 
 628                           ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 631         // Where do we put the next button? 
 633         if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 638             nYOffset 
-= nMaxHeight
; 
 639             if (m_pnRadioWidth
[0] > 0) 
 645             // To the right of this one 
 647             nXOffset 
+= nWidthBtn 
+ nCx1
; 
 650 } // end of wxRadioBox::DoSetSize 
 652 void wxRadioBox::Enable( 
 657     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, 
 658                  wxT("invalid item in wxRadioBox::Enable()") ); 
 660     ::WinEnableWindow((HWND
) m_ahRadioButtons
[nItem
], bEnable
); 
 661 } // end of wxRadioBox::Enable 
 663 bool wxRadioBox::Enable( 
 667     if ( !wxControl::Enable(bEnable
) ) 
 669     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 670         ::WinEnableWindow((HWND
)m_ahRadioButtons
[i
], bEnable
); 
 672 } // end of wxRadioBox::Enable 
 674 int wxRadioBox::FindString( 
 675   const wxString
&                   rsStr
 
 678     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 680         if (rsStr 
== wxGetWindowText(m_ahRadioButtons
[i
]) ) 
 684 } // end of wxRadioBox::FindString 
 686 int wxRadioBox::GetColumnCount() const 
 689 } // end of wxRadioBox::GetColumnCount 
 691 int wxRadioBox::GetCount() const 
 694 } // end of wxRadioBox::GetCount 
 696 wxString 
wxRadioBox::GetLabel( 
 700     wxCHECK_MSG(nItem 
>= 0 && nItem 
< m_nNoItems
, wxT(""), wxT("invalid radiobox index") ); 
 702     return wxGetWindowText(m_ahRadioButtons
[nItem
]); 
 703 } // end of wxRadioBox::GetLabel 
 705 wxSize 
wxRadioBox::GetMaxButtonSize() const 
 710     for (int i 
= 0 ; i 
< m_nNoItems
; i
++) 
 715         if (m_pnRadioWidth
[i
] < 0L) 
 717             GetTextExtent( wxGetWindowText(m_ahRadioButtons
[i
]) 
 723             // Adjust the size to take into account the radio box itself 
 724             // FIXME this is totally bogus! 
 726             nWidth  
+= RADIO_SIZE
; 
 732             nWidth  
= m_pnRadioWidth
[i
]; 
 733             nHeight 
= m_pnRadioHeight
[i
]; 
 735         if (nWidthMax 
< nWidth 
) 
 737         if (nHeightMax 
< nHeight 
) 
 738             nHeightMax 
= nHeight
; 
 740     return(wxSize( nWidthMax
 
 744 } // end of wxRadioBox::GetMaxButtonSize 
 746 int wxRadioBox::GetNumHor() const 
 748     if ( m_windowStyle 
& wxRA_SPECIFY_ROWS 
) 
 750         return (m_nNoItems 
+ m_nMajorDim 
- 1)/m_nMajorDim
; 
 756 } // end of wxRadioBox::GetNumHor 
 758 int wxRadioBox::GetNumVer() const 
 760     if ( m_windowStyle 
& wxRA_SPECIFY_ROWS 
) 
 766         return (m_nNoItems 
+ m_nMajorDim 
- 1)/m_nMajorDim
; 
 768 } // end of wxRadioBox::GetNumVer 
 770 void wxRadioBox::GetPosition( 
 775     wxWindowOS2
*                    pParent 
= GetParent(); 
 776     RECT                            vRect 
= { -1, -1, -1, -1 };; 
 780     for (i 
= 0; i 
< m_nNoItems
; i
++) 
 781         wxFindMaxSize( m_ahRadioButtons
[i
] 
 785         wxFindMaxSize( m_hWnd
 
 790     // Since we now have the absolute screen coords, if there's a parent we 
 791     // must subtract its top left corner 
 793     vPoint
.x 
= vRect
.xLeft
; 
 794     vPoint
.y 
= vRect
.yTop
; 
 799         ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
); 
 805     // We may be faking the client origin. So a window that's really at (0, 30) 
 806     // may appear (to wxWin apps) to be at (0, 0). 
 810         wxPoint                     
vPt(GetParent()->GetClientAreaOrigin()); 
 817 } // end of wxRadioBox::GetPosition 
 819 int wxRadioBox::GetRowCount() const 
 822 } // end of wxRadioBox::GetRowCount 
 824 // Get single selection, for single choice list items 
 825 int wxRadioBox::GetSelection() const 
 827     return m_nSelectedButton
; 
 828 } // end of wxRadioBox::GetSelection 
 830 void wxRadioBox::GetSize( 
 844         wxFindMaxSize( m_hWnd
 
 848     for (i 
= 0; i 
< m_nNoItems
; i
++) 
 849         wxFindMaxSize( m_ahRadioButtons
[i
] 
 853     *pnWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
 854     *pnHeight 
= vRect
.yBottom 
- vRect
.yTop
; 
 855 } // end of wxRadioBox::GetSize 
 857 // Find string for position 
 858 wxString 
wxRadioBox::GetString( 
 862     return wxGetWindowText(m_ahRadioButtons
[nNum
]); 
 863 } // end of wxRadioBox::GetString 
 865 // For single selection items only 
 866 wxString 
wxRadioBox::GetStringSelection() const 
 869     int                             nSel 
= GetSelection(); 
 872         sResult 
= GetString(nSel
); 
 874 } // end of wxRadioBox::GetStringSelection 
 876 wxSize 
wxRadioBox::GetTotalButtonSize( 
 877   const wxSize
&                     rSizeBtn
 
 887     wxGetCharSize( m_hWnd
 
 894     nHeight 
= GetNumVer() * rSizeBtn
.y 
+ (2 * nCy1
); 
 895     nWidth  
= GetNumHor() * (rSizeBtn
.x 
+ nCx1
) + nCx1
; 
 898     // And also wide enough for its label 
 900     GetTextExtent( GetTitle() 
 904     nWidthLabel 
+= RADIO_SIZE
; 
 905     if (nWidthLabel 
> nWidth
) 
 906         nWidth 
= nWidthLabel
; 
 908     return(wxSize( nWidth
 
 912 } // end of wxRadioBox::GetTotalButtonSize 
 914 WXHBRUSH 
wxRadioBox::OnCtlColor( 
 923     HPS                             hPS 
= (HPS
)hwinDC
; // pass in a PS handle in OS/2 
 925     if (GetParent()->GetTransparentBackground()) 
 926         ::GpiSetBackMix(hPS
, BM_LEAVEALONE
); 
 928         ::GpiSetBackMix(hPS
, BM_OVERPAINT
); 
 930     wxColour                        vColBack 
= GetBackgroundColour(); 
 932     ::GpiSetBackColor(hPS
, vColBack
.GetPixel()); 
 933     ::GpiSetColor(hPS
, vColBack
.GetPixel()); 
 936     wxBrush
*                        pBrush 
= wxTheBrushList
->FindOrCreateBrush( vColBack
 
 939     return ((WXHBRUSH
)pBrush
->GetResourceHandle()); 
 940 } // end of wxRadioBox::OnCtlColor 
 942 bool wxRadioBox::OS2Command( 
 947     int                             nSelectedButton 
= -1; 
 949     if (uCmd 
== BN_CLICKED
) 
 955         for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 957             if (wId 
== wxGetWindowId(m_ahRadioButtons
[i
])) 
 963         if (nSelectedButton 
== -1) 
 966             // Just ignore it - due to a hack with WM_NCHITTEST handling in our 
 967             // wnd proc, we can receive dummy click messages when we click near 
 968             // the radiobox edge (this is ugly but Julian wouldn't let me get 
 972         if (nSelectedButton 
!= m_nSelectedButton
) 
 974             m_nSelectedButton 
= nSelectedButton
; 
 975             SendNotificationEvent(); 
 981 } // end of wxRadioBox::OS2Command 
 983 void wxRadioBox::SendNotificationEvent() 
 985     wxCommandEvent                  
vEvent( wxEVT_COMMAND_RADIOBOX_SELECTED
 
 989     vEvent
.SetInt( m_nSelectedButton 
); 
 990     vEvent
.SetString( GetString(m_nSelectedButton
) ); 
 991     vEvent
.SetEventObject(this); 
 992     ProcessCommand(vEvent
); 
 993 } // end of wxRadioBox::SendNotificationEvent 
 995 void wxRadioBox::SetFocus() 
 999         if (m_nSelectedButton 
== -1) 
1000             ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[0]); 
1002             ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[m_nSelectedButton
]); 
1004 } // end of wxRadioBox::SetFocus 
1006 bool wxRadioBox::SetFont( 
1010     if (!wxControl::SetFont(rFont
)) 
1018     // Also set the font of our radio buttons 
1020     WXHFONT                         hFont 
= wxFont(rFont
).GetResourceHandle(); 
1022     for (int n 
= 0; n 
< (int)m_nNoItems
; n
++) 
1024         HWND                        hWndBtn 
= (HWND
)m_ahRadioButtons
[n
]; 
1026         wxOS2SetFont( hWndBtn
 
1029         ::WinInvalidateRect(hWndBtn
, NULL
, FALSE
); 
1032 } // end of wxRadioBox::SetFont 
1034 void wxRadioBox::SetSelection( 
1038     wxCHECK_RET( (nNum 
>= 0) && (nNum 
< m_nNoItems
), wxT("invalid radiobox index") ); 
1040     if (m_nSelectedButton 
>= 0 && m_nSelectedButton 
< m_nNoItems
) 
1041         ::WinSendMsg((HWND
)m_ahRadioButtons
[m_nSelectedButton
], BM_SETCHECK
, (MPARAM
)0, (MPARAM
)0); 
1043     ::WinSendMsg((HWND
)m_ahRadioButtons
[nNum
], BM_SETCHECK
, (MPARAM
)1, (MPARAM
)0); 
1044     ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[nNum
]); 
1045     m_nSelectedButton 
= nNum
; 
1046 } // end of wxRadioBox::SetSelection 
1048 void wxRadioBox::SetString( 
1050 , const wxString
&                   rsLabel
 
1053     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, wxT("invalid radiobox index") ); 
1055     m_pnRadioWidth
[nItem
] = m_pnRadioHeight
[nItem
] = -1; 
1056     ::WinSetWindowText((HWND
)m_ahRadioButtons
[nItem
], rsLabel
.c_str()); 
1057 } // end of wxRadioBox::SetString 
1059 bool wxRadioBox::SetStringSelection( 
1060   const wxString
&                   rsStr
 
1063     int                             nSel 
= FindString(rsStr
); 
1072 } // end of wxRadioBox::SetStringSelection 
1074 bool wxRadioBox::Show( 
1080     if (!wxControl::Show(bShow
)) 
1083     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
1085         ::WinShowWindow((HWND
)m_ahRadioButtons
[i
], (BOOL
)bShow
); 
1088 } // end of wxRadioBox::Show 
1090 // Show a specific button 
1091 void wxRadioBox::Show( 
1096     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, 
1097                  wxT("invalid item in wxRadioBox::Show()") ); 
1099     ::WinShowWindow((HWND
)m_ahRadioButtons
[nItem
], bShow
); 
1100 } // end of wxRadioBox::Show 
1102 void wxRadioBox::SubclassRadioButton( 
1106     HWND                            hwndBtn 
= (HWND
)hWndBtn
; 
1108     fnWndProcRadioBtn 
= (WXFARPROC
)::WinSubclassWindow(hWndBtn
, (PFNWP
)wxRadioBtnWndProc
); 
1109 } // end of wxRadioBox::SubclassRadioButton 
1111 MRESULT 
wxRadioBox::WindowProc( 
1117     return (wxControl::OS2WindowProc( uMsg
 
1121 } // end of wxRadioBox::WindowProc 
1123 // --------------------------------------------------------------------------- 
1124 // window proc for radio buttons 
1125 // --------------------------------------------------------------------------- 
1127 MRESULT 
wxRadioBtnWndProc( 
1138                 USHORT                  uKeyFlags 
= SHORT1FROMMP((MPARAM
)wParam
); 
1140                 if (!(uKeyFlags 
& KC_KEYUP
)) // Key Down event 
1142                     if (uKeyFlags 
& KC_VIRTUALKEY
) 
1144                         wxRadioBox
*             pRadiobox 
= (wxRadioBox 
*)::WinQueryWindowULong( hWnd
 
1147                         USHORT                  uVk 
= SHORT2FROMMP((MPARAM
)lParam
); 
1148                         bool                    bProcessed 
= TRUE
; 
1173                                 // Just to suppress the compiler warning 
1180                             int             nSelOld 
= pRadiobox
->GetSelection(); 
1181                             int             nSelNew 
= pRadiobox
->GetNextItem( nSelOld
 
1183                                                                              ,pRadiobox
->GetWindowStyleFlag() 
1186                             if (nSelNew 
!= nSelOld
) 
1188                                 pRadiobox
->SetSelection(nSelNew
); 
1191                                 // Emulate the button click 
1193                                 pRadiobox
->SendNotificationEvent(); 
1203     return fnWndProcRadioBtn( hWnd
 
1208 } // end of wxRadioBtnWndProc