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
; 
 111     wxGetCharSize( m_hWnd
 
 116     vMaxSize   
= GetMaxButtonSize(); 
 117     nMaxWidth  
= vMaxSize
.x
; 
 118     nMaxHeight 
= vMaxSize
.y
; 
 121     nYOffset 
-= (nMaxHeight 
+ ((3*nCy1
)/2)); 
 126     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 129         // The last button in the row may be wider than the other ones as the 
 130         // radiobox may be wider than the sum of the button widths (as it 
 131         // happens, for example, when the radiobox label is very long) 
 133         bool                        bIsLastInTheRow
; 
 135         if (m_windowStyle 
& wxRA_SPECIFY_COLS
) 
 138             // Item is the last in its row if it is a multiple of the number of 
 139             // columns or if it is just the last item 
 143             bIsLastInTheRow 
= ((n 
% m_nMajorDim
) == 0) || (n 
== m_nNoItems
); 
 145         else // winRA_SPECIFY_ROWS 
 148             // Item is the last in the row if it is in the last columns 
 150             bIsLastInTheRow 
= i 
>= (m_nNoItems
/m_nMajorDim
) * m_nMajorDim
; 
 154         // Is this the start of new row/column? 
 156         if (i 
&& (i 
% m_nMajorDim 
== 0)) 
 158             if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 162                 // Start of new column 
 165                 nXOffset 
+= nMaxWidth 
+ nCx1
; 
 167             else // start of new row 
 170                 nYOffset 
-= nMaxHeight
; 
 171                 if (m_pnRadioWidth
[0] > 0L) 
 181             // Make the button go to the end of radio box 
 183             nWidthBtn 
= nStartX 
+ nWidth 
- nXOffset 
- (2 * nCx1
); 
 184             if (nWidthBtn 
< nMaxWidth
) 
 185                 nWidthBtn 
= nMaxWidth
; 
 190             // Normal button, always of the same size 
 192             nWidthBtn 
= nMaxWidth
; 
 196         // Make all buttons of the same, maximal size - like this they 
 197         // cover the radiobox entirely and the radiobox tooltips are always 
 198         // shown (otherwise they are not when the mouse pointer is in the 
 199         // radiobox part not beYInt32ing to any radiobutton) 
 201         ::WinSetWindowPos( (HWND
)m_ahRadioButtons
[i
] 
 207                           ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 210         // Where do we put the next button? 
 212         if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 217             nYOffset 
-= nMaxHeight
; 
 218             if (m_pnRadioWidth
[0] > 0) 
 224             // To the right of this one 
 226             nXOffset 
+= nWidthBtn 
+ nCx1
; 
 229 } // end of wxRadioBox::AdjustButtons 
 231 void wxRadioBox::Command ( 
 232   wxCommandEvent
&                   rEvent
 
 235     SetSelection (rEvent
.GetInt()); 
 236     ProcessCommand(rEvent
); 
 237 } // end of wxRadioBox::Command 
 239 bool wxRadioBox::ContainsHWND( 
 243     size_t                          nCount 
= GetCount(); 
 246     for (i 
= 0; i 
< nCount
; i
++) 
 248         if (GetRadioButtons()[i
] == hWnd
) 
 252 } // end of wxRadioBox::ContainsHWND 
 254 bool wxRadioBox::Create( 
 257 , const wxString
&                   rsTitle
 
 258 , const wxPoint
&                    rPos
 
 259 , const wxSize
&                     rSize
 
 260 , const wxArrayString
&              asChoices
 
 263 , const wxValidator
&                rVal
 
 264 , const wxString
&                   rsName
 
 267     wxCArrayString 
chs(asChoices
); 
 269     return Create(pParent
, vId
, rsTitle
, rPos
, rSize
, chs
.GetCount(), 
 270                   chs
.GetStrings(), nMajorDim
, lStyle
, rVal
, rsName
); 
 273 bool wxRadioBox::Create( 
 276 , const wxString
&                   rsTitle
 
 277 , const wxPoint
&                    rPos
 
 278 , const wxSize
&                     rSize
 
 280 , const wxString                    asChoices
[] 
 283 , const wxValidator
&                rVal
 
 284 , const wxString
&                   rsName
 
 290     vColour
.Set(wxString("BLACK")); 
 291     m_backgroundColour 
= pParent
->GetBackgroundColour(); 
 292     m_nSelectedButton 
= -1; 
 295     m_nMajorDim     
= nMajorDim 
== 0 ? nNum 
: nMajorDim
; 
 296     m_nNoRowsOrCols 
= nMajorDim
; 
 299     // Common initialization 
 301     if (!CreateControl( pParent
 
 310     if (!OS2CreateControl( "STATIC" 
 318     wxAssociateWinWithHandle(m_hWnd
, this); 
 321     // Some radio boxes test consecutive id. 
 324     (void)NewControlId(); 
 325     m_ahRadioButtons 
= new WXHWND
[nNum
]; 
 326     m_pnRadioWidth   
= new int[nNum
]; 
 327     m_pnRadioHeight  
= new int[nNum
]; 
 329     for (int i 
= 0; i 
< nNum
; i
++) 
 331         m_pnRadioWidth
[i
] = m_pnRadioHeight
[i
] = -1; 
 333         long                        lStyleBtn 
= BS_AUTORADIOBUTTON 
| WS_TABSTOP 
| WS_VISIBLE
; 
 334         int                         nNewId 
= NewControlId(); 
 336         if (i 
== 0 && lStyle 
== 0) 
 337             lStyleBtn 
|= WS_GROUP
; 
 339         HWND                        hWndBtn 
= (WXHWND
)::WinCreateWindow ( GetHwndOf(pParent
) 
 350         lColor 
= (LONG
)vColour
.GetPixel(); 
 351         ::WinSetPresParam( hWndBtn
 
 356         lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 358         ::WinSetPresParam( hWndBtn
 
 367         m_ahRadioButtons
[i
] = (WXHWND
)hWndBtn
; 
 368         SubclassRadioButton((WXHWND
)hWndBtn
); 
 369         wxAssociateWinWithHandle(hWndBtn
, this); 
 370         wxOS2SetFont( hWndBtn
 
 373         ::WinSetWindowULong(hWndBtn
, QWL_USER
, (ULONG
)this); 
 374         m_aSubControls
.Add(nNewId
); 
 378     // Create a dummy radio control to end the group. 
 380     (void)::WinCreateWindow ( GetHwndOf(pParent
) 
 383                              ,WS_GROUP 
| BS_AUTORADIOBUTTON
 
 387                              ,(HMENU
)NewControlId() 
 391     SetFont(*wxSMALL_FONT
); 
 392     fnWndProcRadioBox 
= (WXFARPROC
)::WinSubclassWindow( GetHwnd() 
 393                                                        ,(PFNWP
)wxRadioBoxWndProc
 
 395     ::WinSetWindowULong(GetHwnd(), QWL_USER
, (ULONG
)this); 
 396     lColor 
= (LONG
)vColour
.GetPixel(); 
 397     ::WinSetPresParam( m_hWnd
 
 402     ::WinSetPresParam( m_hWnd
 
 407     lColor 
= (LONG
)m_backgroundColour
.GetPixel(); 
 409     ::WinSetPresParam( m_hWnd
 
 414     ::WinSetPresParam( m_hWnd
 
 428 } // end of wxRadioBox::Create 
 430 wxSize 
wxRadioBox::DoGetBestSize() const 
 432     return (GetTotalButtonSize(GetMaxButtonSize())); 
 433 } // end of WinGuiBase_CRadioBox::DoGetBestSize 
 435 void wxRadioBox::DoSetSize( 
 449 #if RADIOBTN_PARENT_IS_RADIOBOX 
 458     wxSize                          vMaxSize 
= GetMaxButtonSize(); 
 467     m_nSizeFlags 
= nSizeFlags
; 
 468     GetPosition( &nCurrentX
 
 475     if (nX 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 477     if (nY 
== -1 && !(nSizeFlags 
& wxSIZE_ALLOW_MINUS_ONE
)) 
 484     wxGetCharSize( m_hWnd
 
 491     // Attempt to have a look coherent with other platforms: We compute the 
 492     // biggest toggle dim, then we align all items according this value. 
 494     vMaxSize   
= GetMaxButtonSize(); 
 495     nMaxWidth  
= vMaxSize
.x
; 
 496     nMaxHeight 
= vMaxSize
.y
; 
 498     vTotSize   
= GetTotalButtonSize(vMaxSize
); 
 499     nTotWidth  
= vTotSize
.x
; 
 500     nTotHeight 
= vTotSize
.y
; 
 503     // Only change our width/height if asked for 
 507         if (nSizeFlags 
& wxSIZE_AUTO_WIDTH 
) 
 515         if (nSizeFlags 
& wxSIZE_AUTO_HEIGHT
) 
 516             nHeight 
= nTotHeight
; 
 518             nHeight 
= nHeightOld
; 
 521     wxWindowOS2
*                    pParent 
= (wxWindowOS2
*)GetParent(); 
 525         int                         nOS2Height 
= GetOS2ParentHeight(pParent
); 
 527         nYy 
= nOS2Height 
- (nYy 
+ nHeight
); 
 528         nYOffset 
= nYy 
+ nHeight
; 
 534         ::WinQueryWindowRect(HWND_DESKTOP
, &vRect
); 
 535         nYy 
= vRect
.yTop 
- (nYy 
+ nHeight
); 
 537     ::WinSetWindowPos( GetHwnd() 
 543                       ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 547     // Now position all the buttons: the current button will be put at 
 548     // wxPoint(x_offset, y_offset) and the new row/column will start at 
 549     // startX/startY. The size of all buttons will be the same wxSize(maxWidth, 
 550     // maxHeight) except for the buttons in the last column which should extend 
 551     // to the right border of radiobox and thus can be wider than this. 
 553     // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in 
 554     // left to right order and m_majorDim is the number of columns while 
 555     // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and 
 556     // m_majorDim is the number of rows. 
 559     nYOffset 
-= (nMaxHeight 
+ ((3*nCy1
)/2)); 
 564     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 567         // The last button in the row may be wider than the other ones as the 
 568         // radiobox may be wider than the sum of the button widths (as it 
 569         // happens, for example, when the radiobox label is very long) 
 571         bool                        bIsLastInTheRow
; 
 573         if (m_windowStyle 
& wxRA_SPECIFY_COLS
) 
 576             // Item is the last in its row if it is a multiple of the number of 
 577             // columns or if it is just the last item 
 581             bIsLastInTheRow 
= ((n 
% m_nMajorDim
) == 0) || (n 
== m_nNoItems
); 
 583         else // winRA_SPECIFY_ROWS 
 586             // Item is the last in the row if it is in the last columns 
 588             bIsLastInTheRow 
= i 
>= (m_nNoItems
/m_nMajorDim
) * m_nMajorDim
; 
 592         // Is this the start of new row/column? 
 594         if (i 
&& (i 
% m_nMajorDim 
== 0)) 
 596             if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 600                 // Start of new column 
 603                 nXOffset 
+= nMaxWidth 
+ nCx1
; 
 605             else // start of new row 
 608                 nYOffset 
-= nMaxHeight
; 
 609                 if (m_pnRadioWidth
[0] > 0L) 
 619             // Make the button go to the end of radio box 
 621             nWidthBtn 
= nStartX 
+ nWidth 
- nXOffset 
- (2 * nCx1
); 
 622             if (nWidthBtn 
< nMaxWidth
) 
 623                 nWidthBtn 
= nMaxWidth
; 
 628             // Normal button, always of the same size 
 630             nWidthBtn 
= nMaxWidth
; 
 634         // Make all buttons of the same, maximal size - like this they 
 635         // cover the radiobox entirely and the radiobox tooltips are always 
 636         // shown (otherwise they are not when the mouse pointer is in the 
 637         // radiobox part not beinting to any radiobutton) 
 639         ::WinSetWindowPos( (HWND
)m_ahRadioButtons
[i
] 
 645                           ,SWP_ZORDER 
| SWP_SIZE 
| SWP_MOVE 
| SWP_SHOW
 
 647         GetParent()->Refresh(); 
 649         // Where do we put the next button? 
 651         if (m_windowStyle 
& wxRA_SPECIFY_ROWS
) 
 656             nYOffset 
-= nMaxHeight
; 
 657             if (m_pnRadioWidth
[0] > 0) 
 663             // To the right of this one 
 665             nXOffset 
+= nWidthBtn 
+ nCx1
; 
 668 } // end of wxRadioBox::DoSetSize 
 670 void wxRadioBox::Enable( 
 675     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, 
 676                  wxT("invalid item in wxRadioBox::Enable()") ); 
 678     ::WinEnableWindow((HWND
) m_ahRadioButtons
[nItem
], bEnable
); 
 679 } // end of wxRadioBox::Enable 
 681 bool wxRadioBox::Enable( 
 685     if ( !wxControl::Enable(bEnable
) ) 
 687     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 688         ::WinEnableWindow((HWND
)m_ahRadioButtons
[i
], bEnable
); 
 690 } // end of wxRadioBox::Enable 
 692 int wxRadioBox::FindString( 
 693   const wxString
&                   rsStr
 
 696     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 698         if (rsStr 
== wxGetWindowText(m_ahRadioButtons
[i
]) ) 
 702 } // end of wxRadioBox::FindString 
 704 int wxRadioBox::GetColumnCount() const 
 707 } // end of wxRadioBox::GetColumnCount 
 709 int wxRadioBox::GetCount() const 
 712 } // end of wxRadioBox::GetCount 
 714 wxString 
wxRadioBox::GetLabel( 
 718     wxCHECK_MSG(nItem 
>= 0 && nItem 
< m_nNoItems
, wxT(""), wxT("invalid radiobox index") ); 
 720     return wxGetWindowText(m_ahRadioButtons
[nItem
]); 
 721 } // end of wxRadioBox::GetLabel 
 723 wxSize 
wxRadioBox::GetMaxButtonSize() const 
 728     for (int i 
= 0 ; i 
< m_nNoItems
; i
++) 
 733         if (m_pnRadioWidth
[i
] < 0L) 
 735             GetTextExtent( wxGetWindowText(m_ahRadioButtons
[i
]) 
 741             // Adjust the size to take into account the radio box itself 
 742             // FIXME this is totally bogus! 
 744             nWidth  
+= RADIO_SIZE
; 
 750             nWidth  
= m_pnRadioWidth
[i
]; 
 751             nHeight 
= m_pnRadioHeight
[i
]; 
 753         if (nWidthMax 
< nWidth 
) 
 755         if (nHeightMax 
< nHeight 
) 
 756             nHeightMax 
= nHeight
; 
 758     return(wxSize( nWidthMax
 
 762 } // end of wxRadioBox::GetMaxButtonSize 
 764 int wxRadioBox::GetNumHor() const 
 766     if ( m_windowStyle 
& wxRA_SPECIFY_ROWS 
) 
 768         return (m_nNoItems 
+ m_nMajorDim 
- 1)/m_nMajorDim
; 
 774 } // end of wxRadioBox::GetNumHor 
 776 int wxRadioBox::GetNumVer() const 
 778     if ( m_windowStyle 
& wxRA_SPECIFY_ROWS 
) 
 784         return (m_nNoItems 
+ m_nMajorDim 
- 1)/m_nMajorDim
; 
 786 } // end of wxRadioBox::GetNumVer 
 788 void wxRadioBox::GetPosition( 
 793     wxWindowOS2
*                    pParent 
= GetParent(); 
 794     RECT                            vRect 
= { -1, -1, -1, -1 };; 
 798     for (i 
= 0; i 
< m_nNoItems
; i
++) 
 799         wxFindMaxSize( m_ahRadioButtons
[i
] 
 803         wxFindMaxSize( m_hWnd
 
 808     // Since we now have the absolute screen coords, if there's a parent we 
 809     // must subtract its top left corner 
 811     vPoint
.x 
= vRect
.xLeft
; 
 812     vPoint
.y 
= vRect
.yTop
; 
 817         ::WinQueryWindowPos((HWND
)pParent
->GetHWND(), &vSwp
); 
 823     // We may be faking the client origin. So a window that's really at (0, 30) 
 824     // may appear (to wxWin apps) to be at (0, 0). 
 828         wxPoint                     
vPt(GetParent()->GetClientAreaOrigin()); 
 835 } // end of wxRadioBox::GetPosition 
 837 int wxRadioBox::GetRowCount() const 
 840 } // end of wxRadioBox::GetRowCount 
 842 // Get single selection, for single choice list items 
 843 int wxRadioBox::GetSelection() const 
 845     return m_nSelectedButton
; 
 846 } // end of wxRadioBox::GetSelection 
 848 void wxRadioBox::GetSize( 
 862         wxFindMaxSize( m_hWnd
 
 866     for (i 
= 0; i 
< m_nNoItems
; i
++) 
 867         wxFindMaxSize( m_ahRadioButtons
[i
] 
 872         *pnWidth  
= vRect
.xRight 
- vRect
.xLeft
; 
 874         *pnHeight 
= vRect
.yTop 
- vRect
.yBottom
; 
 875 } // end of wxRadioBox::GetSize 
 877 // Find string for position 
 878 wxString 
wxRadioBox::GetString( 
 882     return wxGetWindowText(m_ahRadioButtons
[nNum
]); 
 883 } // end of wxRadioBox::GetString 
 885 // For single selection items only 
 886 wxString 
wxRadioBox::GetStringSelection() const 
 889     int                             nSel 
= GetSelection(); 
 892         sResult 
= GetString(nSel
); 
 894 } // end of wxRadioBox::GetStringSelection 
 896 wxSize 
wxRadioBox::GetTotalButtonSize( 
 897   const wxSize
&                     rSizeBtn
 
 907     wxGetCharSize( m_hWnd
 
 914     nHeight 
= GetNumVer() * rSizeBtn
.y 
+ (2 * nCy1
); 
 915     nWidth  
= GetNumHor() * (rSizeBtn
.x 
+ nCx1
) + nCx1
; 
 918     // And also wide enough for its label 
 920     GetTextExtent( GetTitle() 
 924     nWidthLabel 
+= RADIO_SIZE
; 
 925     if (nWidthLabel 
> nWidth
) 
 926         nWidth 
= nWidthLabel
; 
 928     return(wxSize( nWidth
 
 932 } // end of wxRadioBox::GetTotalButtonSize 
 934 WXHBRUSH 
wxRadioBox::OnCtlColor( 
 943     HPS                             hPS 
= (HPS
)hwinDC
; // pass in a PS handle in OS/2 
 945     if (GetParent()->GetTransparentBackground()) 
 946         ::GpiSetBackMix(hPS
, BM_LEAVEALONE
); 
 948         ::GpiSetBackMix(hPS
, BM_OVERPAINT
); 
 950     wxColour                        vColBack 
= GetBackgroundColour(); 
 952     ::GpiSetBackColor(hPS
, vColBack
.GetPixel()); 
 953     ::GpiSetColor(hPS
, vColBack
.GetPixel()); 
 956     wxBrush
*                        pBrush 
= wxTheBrushList
->FindOrCreateBrush( vColBack
 
 959     return ((WXHBRUSH
)pBrush
->GetResourceHandle()); 
 960 } // end of wxRadioBox::OnCtlColor 
 962 bool wxRadioBox::OS2Command( 
 967     int                             nSelectedButton 
= -1; 
 969     if (uCmd 
== BN_CLICKED
) 
 975         for (int i 
= 0; i 
< m_nNoItems
; i
++) 
 977             if (wId 
== wxGetWindowId(m_ahRadioButtons
[i
])) 
 983         if (nSelectedButton 
== -1) 
 990         if (nSelectedButton 
!= m_nSelectedButton
) 
 992             m_nSelectedButton 
= nSelectedButton
; 
 993             SendNotificationEvent(); 
 999 } // end of wxRadioBox::OS2Command 
1001 void wxRadioBox::SendNotificationEvent() 
1003     wxCommandEvent                  
vEvent( wxEVT_COMMAND_RADIOBOX_SELECTED
 
1007     vEvent
.SetInt( m_nSelectedButton 
); 
1008     vEvent
.SetString( GetString(m_nSelectedButton
) ); 
1009     vEvent
.SetEventObject(this); 
1010     ProcessCommand(vEvent
); 
1011 } // end of wxRadioBox::SendNotificationEvent 
1013 void wxRadioBox::SetFocus() 
1017         if (m_nSelectedButton 
== -1) 
1018             ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[0]); 
1020             ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[m_nSelectedButton
]); 
1022 } // end of wxRadioBox::SetFocus 
1024 bool wxRadioBox::SetFont( 
1028     if (!wxControl::SetFont(rFont
)) 
1036     // Also set the font of our radio buttons 
1038     for (int n 
= 0; n 
< (int)m_nNoItems
; n
++) 
1040         HWND                        hWndBtn 
= (HWND
)m_ahRadioButtons
[n
]; 
1042         wxOS2SetFont( hWndBtn
 
1045         ::WinInvalidateRect(hWndBtn
, NULL
, FALSE
); 
1048 } // end of wxRadioBox::SetFont 
1050 void wxRadioBox::SetSelection( 
1054     wxCHECK_RET( (nNum 
>= 0) && (nNum 
< m_nNoItems
), wxT("invalid radiobox index") ); 
1056     if (m_nSelectedButton 
>= 0 && m_nSelectedButton 
< m_nNoItems
) 
1057         ::WinSendMsg((HWND
)m_ahRadioButtons
[m_nSelectedButton
], BM_SETCHECK
, (MPARAM
)0, (MPARAM
)0); 
1059     ::WinSendMsg((HWND
)m_ahRadioButtons
[nNum
], BM_SETCHECK
, (MPARAM
)1, (MPARAM
)0); 
1060     ::WinSetFocus(HWND_DESKTOP
, (HWND
)m_ahRadioButtons
[nNum
]); 
1061     m_nSelectedButton 
= nNum
; 
1062 } // end of wxRadioBox::SetSelection 
1064 void wxRadioBox::SetString( 
1066 , const wxString
&                   rsLabel
 
1069     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, wxT("invalid radiobox index") ); 
1071     m_pnRadioWidth
[nItem
] = m_pnRadioHeight
[nItem
] = -1; 
1072     ::WinSetWindowText((HWND
)m_ahRadioButtons
[nItem
], rsLabel
.c_str()); 
1073 } // end of wxRadioBox::SetString 
1075 bool wxRadioBox::SetStringSelection( 
1076   const wxString
&                   rsStr
 
1079     int                             nSel 
= FindString(rsStr
); 
1088 } // end of wxRadioBox::SetStringSelection 
1090 bool wxRadioBox::Show( 
1094     if (!wxControl::Show(bShow
)) 
1097     for (int i 
= 0; i 
< m_nNoItems
; i
++) 
1099         ::WinShowWindow((HWND
)m_ahRadioButtons
[i
], (BOOL
)bShow
); 
1102 } // end of wxRadioBox::Show 
1104 // Show a specific button 
1105 void wxRadioBox::Show( 
1110     wxCHECK_RET( nItem 
>= 0 && nItem 
< m_nNoItems
, 
1111                  wxT("invalid item in wxRadioBox::Show()") ); 
1113     ::WinShowWindow((HWND
)m_ahRadioButtons
[nItem
], bShow
); 
1114 } // end of wxRadioBox::Show 
1116 void wxRadioBox::SubclassRadioButton( 
1120     fnWndProcRadioBtn 
= (WXFARPROC
)::WinSubclassWindow(hWndBtn
, (PFNWP
)wxRadioBtnWndProc
); 
1121 } // end of wxRadioBox::SubclassRadioButton 
1123 MRESULT 
wxRadioBox::WindowProc( 
1129     return (wxControl::OS2WindowProc( uMsg
 
1133 } // end of wxRadioBox::WindowProc 
1135 // --------------------------------------------------------------------------- 
1136 // window proc for radio buttons 
1137 // --------------------------------------------------------------------------- 
1139 MRESULT 
wxRadioBtnWndProc( 
1150                 USHORT                  uKeyFlags 
= SHORT1FROMMP((MPARAM
)wParam
); 
1152                 if (!(uKeyFlags 
& KC_KEYUP
)) // Key Down event 
1154                     if (uKeyFlags 
& KC_VIRTUALKEY
) 
1156                         wxRadioBox
*             pRadiobox 
= (wxRadioBox 
*)::WinQueryWindowULong( hWnd
 
1159                         USHORT                  uVk 
= SHORT2FROMMP((MPARAM
)lParam
); 
1160                         bool                    bProcessed 
= TRUE
; 
1185                                 // Just to suppress the compiler warning 
1192                             int             nSelOld 
= pRadiobox
->GetSelection(); 
1193                             int             nSelNew 
= pRadiobox
->GetNextItem( nSelOld
 
1195                                                                              ,pRadiobox
->GetWindowStyleFlag() 
1198                             if (nSelNew 
!= nSelOld
) 
1200                                 pRadiobox
->SetSelection(nSelNew
); 
1203                                 // Emulate the button click 
1205                                 pRadiobox
->SendNotificationEvent(); 
1215     return fnWndProcRadioBtn( hWnd
 
1220 } // end of wxRadioBtnWndProc 
1222 MRESULT EXPENTRY 
wxRadioBoxWndProc( 
1229     return (fnWndProcRadioBox( hWnd
 
1235 } // end of wxRadioBoxWndProc