]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/radiobox.cpp
fix getting tooltip colors for GTK 2.11
[wxWidgets.git] / src / os2 / radiobox.cpp
index 019dae4ab02b28f231595eb8cc7dd50ddb5debc5..6b09f2264606d62d78942b13f6f6ab3bd797f631 100644 (file)
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#if wxUSE_RADIOBOX
+
+#include "wx/radiobox.h"
+
 #ifndef WX_PRECOMP
     #include <stdio.h>
 #ifndef WX_PRECOMP
     #include <stdio.h>
-    #include "wx/setup.h"
-    #include "wx/wxchar.h"
+    #include "wx/crt.h"
     #include "wx/string.h"
     #include "wx/bitmap.h"
     #include "wx/brush.h"
     #include "wx/string.h"
     #include "wx/bitmap.h"
     #include "wx/brush.h"
-    #include "wx/radiobox.h"
 #endif
 
 #include "wx/os2/private.h"
 #endif
 
 #include "wx/os2/private.h"
@@ -46,10 +48,11 @@ MRESULT EXPENTRY wxRadioBoxWndProc( HWND   hWnd
 // global vars
 // ---------------------------------------------------------------------------
 
 // global vars
 // ---------------------------------------------------------------------------
 
-// the pointer to standard radio button wnd proc
 extern void  wxAssociateWinWithHandle( HWND         hWnd
                                       ,wxWindowOS2* pWin
                                      );
 extern void  wxAssociateWinWithHandle( HWND         hWnd
                                       ,wxWindowOS2* pWin
                                      );
+extern void wxRemoveHandleAssociation( wxWindowOS2 *pWin );
+// the pointer to standard radio button & box wnd procs
 static WXFARPROC                    fnWndProcRadioBtn = NULL;
 static WXFARPROC                    fnWndProcRadioBox = NULL;
 
 static WXFARPROC                    fnWndProcRadioBtn = NULL;
 static WXFARPROC                    fnWndProcRadioBox = NULL;
 
@@ -66,7 +69,6 @@ wxRadioBox::wxRadioBox()
 {
     m_nSelectedButton = -1;
     m_nNoItems = 0;
 {
     m_nSelectedButton = -1;
     m_nNoItems = 0;
-    m_nNoRowsOrCols = 0;
     m_ahRadioButtons = NULL;
     m_pnRadioWidth = NULL;
     m_pnRadioHeight = NULL;
     m_ahRadioButtons = NULL;
     m_pnRadioWidth = NULL;
     m_pnRadioHeight = NULL;
@@ -76,11 +78,17 @@ wxRadioBox::~wxRadioBox()
 {
     m_isBeingDeleted = true;
 
 {
     m_isBeingDeleted = true;
 
+    if (m_hWnd)
+        wxRemoveHandleAssociation(this);
     if (m_ahRadioButtons)
     {
     if (m_ahRadioButtons)
     {
-        int                         i;
-        for (i = 0; i < m_nNoItems; i++)
+        for (unsigned int i = 0; i < m_nNoItems; i++)
+        {
+            wxWindow* pWin = wxFindWinFromHandle((WXHWND)m_ahRadioButtons[i]);
+            wxRemoveHandleAssociation(pWin);
+
             ::WinDestroyWindow((HWND)m_ahRadioButtons[i]);
             ::WinDestroyWindow((HWND)m_ahRadioButtons[i]);
+    }
         delete[] m_ahRadioButtons;
     }
     if (m_pnRadioWidth)
         delete[] m_ahRadioButtons;
     }
     if (m_pnRadioWidth)
@@ -89,157 +97,16 @@ wxRadioBox::~wxRadioBox()
         delete[] m_pnRadioHeight;
 } // end of wxRadioBox::~wxRadioBox
 
         delete[] m_pnRadioHeight;
 } // end of wxRadioBox::~wxRadioBox
 
-void wxRadioBox::AdjustButtons( int nX,
-                                int nY,
-                                int nWidth,
-                                int nHeight,
-                                int WXUNUSED(nSizeFlags) )
-{
-    wxSize vMaxSize;
-    int    nXOffset = nX;
-    int    nYOffset = nY + nHeight;
-    int    nCx1;
-    int    nCy1;
-    int    nStartX;
-    int    nStartY;
-    int    nMaxWidth;
-    int    nMaxHeight;
-    wxFont vFont = GetFont();
-
-    wxGetCharSize( m_hWnd
-                  ,&nCx1
-                  ,&nCy1
-                  ,&vFont
-                 );
-    vMaxSize   = GetMaxButtonSize();
-    nMaxWidth  = vMaxSize.x;
-    nMaxHeight = vMaxSize.y;
-
-    nXOffset += nCx1;
-    nYOffset -= (nMaxHeight + ((3*nCy1)/2));
-
-    nStartX = nXOffset;
-    nStartY = nYOffset;
-
-    for (int i = 0; i < m_nNoItems; i++)
-    {
-        //
-        // The last button in the row may be wider than the other ones as the
-        // radiobox may be wider than the sum of the button widths (as it
-        // happens, for example, when the radiobox label is very long)
-        //
-        bool                        bIsLastInTheRow;
-
-        if (m_windowStyle & wxRA_SPECIFY_COLS)
-        {
-            //
-            // Item is the last in its row if it is a multiple of the number of
-            // columns or if it is just the last item
-            //
-            int                     n = i + 1;
-
-            bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems);
-        }
-        else // winRA_SPECIFY_ROWS
-        {
-            //
-            // Item is the last in the row if it is in the last columns
-            //
-            bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim();
-        }
-
-        //
-        // Is this the start of new row/column?
-        //
-        if (i && (i % GetMajorDim() == 0))
-        {
-            if (m_windowStyle & wxRA_SPECIFY_ROWS)
-            {
-
-                //
-                // Start of new column
-                //
-                nYOffset = nStartY;
-                nXOffset += nMaxWidth + nCx1;
-            }
-            else // start of new row
-            {
-                nXOffset = nStartX;
-                nYOffset -= nMaxHeight;
-                if (m_pnRadioWidth[0] > 0L)
-                    nYOffset -= nCy1/2;
-            }
-        }
-
-        int                         nWidthBtn;
-
-        if (bIsLastInTheRow)
-        {
-            //
-            // Make the button go to the end of radio box
-            //
-            nWidthBtn = nStartX + nWidth - nXOffset - (2 * nCx1);
-            if (nWidthBtn < nMaxWidth)
-                nWidthBtn = nMaxWidth;
-        }
-        else
-        {
-            //
-            // Normal button, always of the same size
-            //
-            nWidthBtn = nMaxWidth;
-        }
-
-        //
-        // Make all buttons of the same, maximal size - like this they
-        // cover the radiobox entirely and the radiobox tooltips are always
-        // shown (otherwise they are not when the mouse pointer is in the
-        // radiobox part not belonging to any radiobutton)
-        //
-        ::WinSetWindowPos( (HWND)m_ahRadioButtons[i]
-                          ,HWND_TOP
-                          ,(LONG)nXOffset
-                          ,(LONG)nYOffset
-                          ,(LONG)nWidthBtn
-                          ,(LONG)nMaxHeight
-                          ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
-                         );
-        //
-        // Where do we put the next button?
-        //
-        if (m_windowStyle & wxRA_SPECIFY_ROWS)
-        {
-            //
-            // Below this one
-            //
-            nYOffset -= nMaxHeight;
-            if (m_pnRadioWidth[0] > 0)
-                nYOffset -= nCy1/2;
-        }
-        else
-        {
-            //
-            // To the right of this one
-            //
-            nXOffset += nWidthBtn + nCx1;
-        }
-    }
-} // end of wxRadioBox::AdjustButtons
-
-void wxRadioBox::Command (
-  wxCommandEvent&                   rEvent
-)
+void wxRadioBox::Command ( wxCommandEvent& rEvent )
 {
     SetSelection (rEvent.GetInt());
     ProcessCommand(rEvent);
 } // end of wxRadioBox::Command
 
 {
     SetSelection (rEvent.GetInt());
     ProcessCommand(rEvent);
 } // end of wxRadioBox::Command
 
-bool wxRadioBox::ContainsHWND(
-  WXHWND                            hWnd
-) const
+bool wxRadioBox::ContainsHWND( WXHWND hWnd ) const
 {
 {
-    size_t                          nCount = GetCount();
-    size_t                          i;
+    unsigned int nCount = GetCount();
+    unsigned int i;
 
     for (i = 0; i < nCount; i++)
     {
 
     for (i = 0; i < nCount; i++)
     {
@@ -249,18 +116,16 @@ bool wxRadioBox::ContainsHWND(
     return false;
 } // end of wxRadioBox::ContainsHWND
 
     return false;
 } // end of wxRadioBox::ContainsHWND
 
-bool wxRadioBox::Create(
-  wxWindow*                         pParent
-, wxWindowID                        vId
-, const wxString&                   rsTitle
-, const wxPoint&                    rPos
-, const wxSize&                     rSize
-, const wxArrayString&              asChoices
-, int                               nMajorDim
-, long                              lStyle
-, const wxValidator&                rVal
-, const wxString&                   rsName
-)
+bool wxRadioBox::Create( wxWindow* pParent,
+                         wxWindowID vId,
+                         const wxString& rsTitle,
+                         const wxPoint& rPos,
+                         const wxSize& rSize,
+                         const wxArrayString& asChoices,
+                         int nMajorDim,
+                         long lStyle,
+                         const wxValidator& rVal,
+                         const wxString& rsName )
 {
     wxCArrayString chs(asChoices);
 
 {
     wxCArrayString chs(asChoices);
 
@@ -268,24 +133,22 @@ bool wxRadioBox::Create(
                   chs.GetStrings(), nMajorDim, lStyle, rVal, rsName);
 }
 
                   chs.GetStrings(), nMajorDim, lStyle, rVal, rsName);
 }
 
-bool wxRadioBox::Create(
-  wxWindow*                         pParent
-, wxWindowID                        vId
-, const wxString&                   rsTitle
-, const wxPoint&                    rPos
-, const wxSize&                     rSize
-, int                               nNum
-, const wxString                    asChoices[]
-, int                               nMajorDim
-, long                              lStyle
-, const wxValidator&                rVal
-, const wxString&                   rsName
-)
-{
-    wxColour                        vColour;
-    LONG                            lColor;
+bool wxRadioBox::Create( wxWindow* pParent,
+                         wxWindowID vId,
+                         const wxString& rsTitle,
+                         const wxPoint& rPos,
+                         const wxSize& rSize,
+                         int nNum,
+                         const wxString asChoices[],
+                         int nMajorDim,
+                         long lStyle,
+                         const wxValidator& rVal,
+                         const wxString& rsName )
+{
+    wxColour vColour(*wxBLACK);
+    LONG     lColor;
+    HWND     hWndParent = GetHwndOf(pParent);
 
 
-    vColour.Set(wxString(wxT("BLACK")));
     m_backgroundColour = pParent->GetBackgroundColour();
     m_nSelectedButton = -1;
     m_nNoItems = 0;
     m_backgroundColour = pParent->GetBackgroundColour();
     m_nSelectedButton = -1;
     m_nNoItems = 0;
@@ -315,14 +178,9 @@ bool wxRadioBox::Create(
     //
     // Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows
     //
     //
     // Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows
     //
-    m_nNoItems = nNum;
+    m_nNoItems = (unsigned int)nNum;
     SetMajorDim(nMajorDim == 0 ? nNum : nMajorDim, lStyle);
     SetMajorDim(nMajorDim == 0 ? nNum : nMajorDim, lStyle);
-    m_nNoRowsOrCols = nMajorDim;
 
 
-    //
-    // Some radio boxes test consecutive id.
-    //
-    (void)NewControlId();
     m_ahRadioButtons = new WXHWND[nNum];
     m_pnRadioWidth   = new int[nNum];
     m_pnRadioHeight  = new int[nNum];
     m_ahRadioButtons = new WXHWND[nNum];
     m_pnRadioWidth   = new int[nNum];
     m_pnRadioHeight  = new int[nNum];
@@ -330,41 +188,42 @@ bool wxRadioBox::Create(
     for (int i = 0; i < nNum; i++)
     {
         m_pnRadioWidth[i] = m_pnRadioHeight[i] = -1;
     for (int i = 0; i < nNum; i++)
     {
         m_pnRadioWidth[i] = m_pnRadioHeight[i] = -1;
-
-        long                        lStyleBtn = BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE;
+        long                        lStyleBtn = BS_AUTORADIOBUTTON | WS_VISIBLE;
         int                         nNewId = NewControlId();
 
         int                         nNewId = NewControlId();
 
-        if (i == 0 && lStyle == 0)
-            lStyleBtn |= WS_GROUP;
-
-        HWND                        hWndBtn = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent)
-                                                                         ,WC_BUTTON
-                                                                         ,::wxPMTextToLabel(asChoices[i])
-                                                                         ,lStyleBtn
-                                                                         ,0, 0, 0, 0
-                                                                         ,GetWinHwnd(pParent)
-                                                                         ,HWND_TOP
-                                                                         ,(HMENU)nNewId
-                                                                         ,NULL
-                                                                         ,NULL
+        if (i == 0)
+            lStyleBtn |= WS_GROUP | WS_TABSTOP;
+
+        wxString                    sLabel = ::wxPMTextToLabel(asChoices[i]);
+
+        HWND                        hWndBtn = (WXHWND)::WinCreateWindow ( hWndParent,
+                                                                          WC_BUTTON,
+                                                                          sLabel.c_str(),
+                                                                          lStyleBtn,
+                                                                          0, 0, 0, 0,
+                                                                          hWndParent,
+                                                                          HWND_BOTTOM,
+                                                                          (HMENU)nNewId,
+                                                                          NULL,
+                                                                          NULL
                                                                         );
                                                                         );
+        if (!hWndBtn)
+        {
+            return false;
+        }
         lColor = (LONG)vColour.GetPixel();
         ::WinSetPresParam( hWndBtn
                           ,PP_FOREGROUNDCOLOR
                           ,sizeof(LONG)
                           ,(PVOID)&lColor
                          );
         lColor = (LONG)vColour.GetPixel();
         ::WinSetPresParam( hWndBtn
                           ,PP_FOREGROUNDCOLOR
                           ,sizeof(LONG)
                           ,(PVOID)&lColor
                          );
-        lColor = (LONG)m_backgroundColour.GetPixel();
 
 
+        lColor = (LONG)m_backgroundColour.GetPixel();
         ::WinSetPresParam( hWndBtn
                           ,PP_BACKGROUNDCOLOR
                           ,sizeof(LONG)
                           ,(PVOID)&lColor
                          );
         ::WinSetPresParam( hWndBtn
                           ,PP_BACKGROUNDCOLOR
                           ,sizeof(LONG)
                           ,(PVOID)&lColor
                          );
-        if (!hWndBtn)
-        {
-            return false;
-        }
         m_ahRadioButtons[i] = (WXHWND)hWndBtn;
         SubclassRadioButton((WXHWND)hWndBtn);
         wxAssociateWinWithHandle(hWndBtn, this);
         m_ahRadioButtons[i] = (WXHWND)hWndBtn;
         SubclassRadioButton((WXHWND)hWndBtn);
         wxAssociateWinWithHandle(hWndBtn, this);
@@ -376,20 +235,19 @@ bool wxRadioBox::Create(
     }
 
     //
     }
 
     //
-    // Create a dummy radio control to end the group.
+    // Create a dummy control to end the group.
     //
     //
-    (void)::WinCreateWindow ( GetHwndOf(pParent),
+    (void)::WinCreateWindow ( hWndParent,
                               WC_BUTTON,
                               "",
                               WC_BUTTON,
                               "",
-                              WS_GROUP | BS_AUTORADIOBUTTON,
+                              WS_GROUP,
                               0, 0, 0, 0,
                               0, 0, 0, 0,
-                              GetWinHwnd(pParent),
+                              hWndParent,
                               HWND_TOP,
                               (HMENU)NewControlId(),
                               NULL,
                               NULL
                             );
                               HWND_TOP,
                               (HMENU)NewControlId(),
                               NULL,
                               NULL
                             );
-    SetFont(*wxSMALL_FONT);
     fnWndProcRadioBox = (WXFARPROC)::WinSubclassWindow( GetHwnd()
                                                        ,(PFNWP)wxRadioBoxWndProc
                                                       );
     fnWndProcRadioBox = (WXFARPROC)::WinSubclassWindow( GetHwnd()
                                                        ,(PFNWP)wxRadioBoxWndProc
                                                       );
@@ -400,23 +258,13 @@ bool wxRadioBox::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-    ::WinSetPresParam( m_hWnd
-                      ,PP_BORDERDARKCOLOR
-                      ,sizeof(LONG)
-                      ,(PVOID)&lColor
-                     );
-    lColor = (LONG)m_backgroundColour.GetPixel();
 
 
+    lColor = (LONG)m_backgroundColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_BACKGROUNDCOLOR
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
     ::WinSetPresParam( m_hWnd
                       ,PP_BACKGROUNDCOLOR
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-    ::WinSetPresParam( m_hWnd
-                      ,PP_BORDERLIGHTCOLOR
-                      ,sizeof(LONG)
-                      ,(PVOID)&lColor
-                     );
     SetXComp(0);
     SetYComp(0);
     SetSelection(0);
     SetXComp(0);
     SetYComp(0);
     SetSelection(0);
@@ -431,7 +279,7 @@ bool wxRadioBox::Create(
 wxSize wxRadioBox::DoGetBestSize() const
 {
     return (GetTotalButtonSize(GetMaxButtonSize()));
 wxSize wxRadioBox::DoGetBestSize() const
 {
     return (GetTotalButtonSize(GetMaxButtonSize()));
-} // end of WinGuiBase_CRadioBox::DoGetBestSize
+} // end of wxRadioBox::DoGetBestSize
 
 void wxRadioBox::DoSetSize(
   int                               nX
 
 void wxRadioBox::DoSetSize(
   int                               nX
@@ -441,19 +289,17 @@ void wxRadioBox::DoSetSize(
 , int                               nSizeFlags
 )
 {
 , int                               nSizeFlags
 )
 {
+    //
+    // Input parameters assume wxWidgets coordinate system
+    //
     int                             nCurrentX;
     int                             nCurrentY;
     int                             nWidthOld;
     int                             nHeightOld;
     int                             nXx = nX;
     int                             nYy = nY;
     int                             nCurrentX;
     int                             nCurrentY;
     int                             nWidthOld;
     int                             nHeightOld;
     int                             nXx = nX;
     int                             nYy = nY;
-#if RADIOBTN_PARENT_IS_RADIOBOX
-    int                             nXOffset = 0;
-    int                             nYOffset = 0;
-#else
     int                             nXOffset = nXx;
     int                             nYOffset = nYy;
     int                             nXOffset = nXx;
     int                             nYOffset = nYy;
-#endif
     int                             nCx1;
     int                             nCy1;
     wxSize                          vMaxSize = GetMaxButtonSize();
     int                             nCx1;
     int                             nCy1;
     wxSize                          vMaxSize = GetMaxButtonSize();
@@ -520,22 +366,19 @@ void wxRadioBox::DoSetSize(
             nHeight = nHeightOld;
     }
 
             nHeight = nHeightOld;
     }
 
+    //
+    // Now convert to OS/2 coordinate system
+    //
     wxWindowOS2*                    pParent = (wxWindowOS2*)GetParent();
     wxWindowOS2*                    pParent = (wxWindowOS2*)GetParent();
-
     if (pParent)
     if (pParent)
-    {
-        int                         nOS2Height = GetOS2ParentHeight(pParent);
-
-        nYy = nOS2Height - (nYy + nHeight);
-        nYOffset = nYy + nHeight;
-    }
+        nYy = GetOS2ParentHeight(pParent) - nYy - nHeight;
     else
     {
         RECTL                       vRect;
     else
     {
         RECTL                       vRect;
-
         ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
         ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
-        nYy = vRect.yTop - (nYy + nHeight);
+        nYy = vRect.yTop - nYy - nHeight;
     }
     }
+    nYOffset = nYy + nHeight;
     ::WinSetWindowPos( GetHwnd()
                       ,HWND_TOP
                       ,(LONG)nXx
     ::WinSetWindowPos( GetHwnd()
                       ,HWND_TOP
                       ,(LONG)nXx
@@ -563,14 +406,14 @@ void wxRadioBox::DoSetSize(
     nStartX = nXOffset;
     nStartY = nYOffset;
 
     nStartX = nXOffset;
     nStartY = nYOffset;
 
-    for (int i = 0; i < m_nNoItems; i++)
+    for (unsigned int i = 0; i < m_nNoItems; i++)
     {
         //
         // The last button in the row may be wider than the other ones as the
         // radiobox may be wider than the sum of the button widths (as it
         // happens, for example, when the radiobox label is very long)
         //
     {
         //
         // The last button in the row may be wider than the other ones as the
         // radiobox may be wider than the sum of the button widths (as it
         // happens, for example, when the radiobox label is very long)
         //
-        bool                        bIsLastInTheRow;
+        bool bIsLastInTheRow;
 
         if (m_windowStyle & wxRA_SPECIFY_COLS)
         {
 
         if (m_windowStyle & wxRA_SPECIFY_COLS)
         {
@@ -580,7 +423,7 @@ void wxRadioBox::DoSetSize(
             //
             int                  n = i + 1;
 
             //
             int                  n = i + 1;
 
-            bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems);
+            bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == (int)m_nNoItems);
         }
         else // winRA_SPECIFY_ROWS
         {
         }
         else // winRA_SPECIFY_ROWS
         {
@@ -597,7 +440,6 @@ void wxRadioBox::DoSetSize(
         {
             if (m_windowStyle & wxRA_SPECIFY_ROWS)
             {
         {
             if (m_windowStyle & wxRA_SPECIFY_ROWS)
             {
-
                 //
                 // Start of new column
                 //
                 //
                 // Start of new column
                 //
@@ -639,7 +481,7 @@ void wxRadioBox::DoSetSize(
         // radiobox part not belonging to any radiobutton)
         //
         ::WinSetWindowPos( (HWND)m_ahRadioButtons[i]
         // radiobox part not belonging to any radiobutton)
         //
         ::WinSetWindowPos( (HWND)m_ahRadioButtons[i]
-                          ,HWND_TOP
+                          ,HWND_BOTTOM
                           ,(LONG)nXOffset
                           ,(LONG)nYOffset
                           ,(LONG)nWidthBtn
                           ,(LONG)nXOffset
                           ,(LONG)nYOffset
                           ,(LONG)nWidthBtn
@@ -668,7 +510,7 @@ void wxRadioBox::DoSetSize(
     }
 } // end of wxRadioBox::DoSetSize
 
     }
 } // end of wxRadioBox::DoSetSize
 
-bool wxRadioBox::Enable(int nItem, bool bEnable)
+bool wxRadioBox::Enable(unsigned int nItem, bool bEnable)
 {
     wxCHECK_MSG( IsValid(nItem), false,
                  wxT("invalid item in wxRadioBox::Enable()") );
 {
     wxCHECK_MSG( IsValid(nItem), false,
                  wxT("invalid item in wxRadioBox::Enable()") );
@@ -677,18 +519,16 @@ bool wxRadioBox::Enable(int nItem, bool bEnable)
     return true;
 } // end of wxRadioBox::Enable
 
     return true;
 } // end of wxRadioBox::Enable
 
-bool wxRadioBox::Enable(
-  bool                              bEnable
-)
+bool wxRadioBox::Enable(bool bEnable)
 {
     if ( !wxControl::Enable(bEnable) )
         return false;
 {
     if ( !wxControl::Enable(bEnable) )
         return false;
-    for (int i = 0; i < m_nNoItems; i++)
+    for (unsigned int i = 0; i < m_nNoItems; i++)
         ::WinEnableWindow((HWND)m_ahRadioButtons[i], bEnable);
     return true;
 } // end of wxRadioBox::Enable
 
         ::WinEnableWindow((HWND)m_ahRadioButtons[i], bEnable);
     return true;
 } // end of wxRadioBox::Enable
 
-int wxRadioBox::GetCount() const
+unsigned int wxRadioBox::GetCount() const
 {
     return m_nNoItems;
 } // end of wxRadioBox::GetCount
 {
     return m_nNoItems;
 } // end of wxRadioBox::GetCount
@@ -702,13 +542,13 @@ wxString wxRadioBox::GetLabel(int nItem) const
 
 wxSize wxRadioBox::GetMaxButtonSize() const
 {
 
 wxSize wxRadioBox::GetMaxButtonSize() const
 {
-    int                             nWidthMax = 0;
-    int                             nHeightMax = 0;
+    int nWidthMax = 0;
+    int nHeightMax = 0;
 
 
-    for (int i = 0 ; i < m_nNoItems; i++)
+    for (unsigned int i = 0 ; i < m_nNoItems; i++)
     {
     {
-        int                         nWidth;
-        int                         nHeight;
+        int nWidth;
+        int nHeight;
 
         if (m_pnRadioWidth[i] < 0L)
         {
 
         if (m_pnRadioWidth[i] < 0L)
         {
@@ -739,55 +579,6 @@ wxSize wxRadioBox::GetMaxButtonSize() const
     return maxsize;
 } // end of wxRadioBox::GetMaxButtonSize
 
     return maxsize;
 } // end of wxRadioBox::GetMaxButtonSize
 
-void wxRadioBox::GetPosition( int* pnX,
-                              int* pnY ) const
-{
-    wxWindowOS2*                    pParent = GetParent();
-    RECT                            vRect = { -1, -1, -1, -1 };
-    POINTL                          vPoint;
-    int                             i;
-
-    for (i = 0; i < m_nNoItems; i++)
-        wxFindMaxSize( m_ahRadioButtons[i]
-                      ,&vRect
-                     );
-    if (m_hWnd)
-        wxFindMaxSize( m_hWnd
-                      ,&vRect
-                     );
-
-    //
-    // Since we now have the absolute screen coords, if there's a parent we
-    // must subtract its top left corner
-    //
-    vPoint.x = vRect.xLeft;
-    vPoint.y = vRect.yTop;
-    if (pParent)
-    {
-        SWP                             vSwp;
-
-        ::WinQueryWindowPos((HWND)pParent->GetHWND(), &vSwp);
-        vPoint.x = vSwp.x;
-        vPoint.y = vSwp.y;
-    }
-
-    //
-    // We may be faking the client origin. So a window that's really at (0, 30)
-    // may appear (to wxWin apps) to be at (0, 0).
-    //
-    if (GetParent())
-    {
-        wxPoint                     vPt(GetParent()->GetClientAreaOrigin());
-
-        vPoint.x = vPt.x;
-        vPoint.y = vPt.y;
-    }
-    if (pnX)
-        *pnX = vPoint.x;
-    if (pnY)
-        *pnY = vPoint.y;
-} // end of wxRadioBox::GetPosition
-
 // Get single selection, for single choice list items
 int wxRadioBox::GetSelection() const
 {
 // Get single selection, for single choice list items
 int wxRadioBox::GetSelection() const
 {
@@ -796,8 +587,7 @@ int wxRadioBox::GetSelection() const
 
 void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const
 {
 
 void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const
 {
-    RECT                            vRect;
-    int                             i;
+    RECT vRect;
 
     vRect.xLeft   = -1;
     vRect.xRight  = -1;
 
     vRect.xLeft   = -1;
     vRect.xRight  = -1;
@@ -805,14 +595,10 @@ void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const
     vRect.yBottom = -1;
 
     if (m_hWnd)
     vRect.yBottom = -1;
 
     if (m_hWnd)
-        wxFindMaxSize( m_hWnd
-                      ,&vRect
-                     );
+        wxFindMaxSize( m_hWnd, &vRect );
 
 
-    for (i = 0; i < m_nNoItems; i++)
-        wxFindMaxSize( m_ahRadioButtons[i]
-                      ,&vRect
-                     );
+    for (unsigned int i = 0; i < m_nNoItems; i++)
+        wxFindMaxSize( m_ahRadioButtons[i], &vRect );
 
     if (pnWidth)
         *pnWidth  = vRect.xRight - vRect.xLeft;
 
     if (pnWidth)
         *pnWidth  = vRect.xRight - vRect.xLeft;
@@ -821,21 +607,21 @@ void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const
 } // end of wxRadioBox::GetSize
 
 // Find string for position
 } // end of wxRadioBox::GetSize
 
 // Find string for position
-wxString wxRadioBox::GetString(
-  int                               nNum
-) const
+wxString wxRadioBox::GetString(unsigned int nNum) const
 {
 {
+    wxCHECK_MSG( IsValid(nNum), wxEmptyString, wxT("invalid radiobox index") );
     return wxGetWindowText(m_ahRadioButtons[nNum]);
 } // end of wxRadioBox::GetString
 
 // For single selection items only
 wxString wxRadioBox::GetStringSelection() const
 {
     return wxGetWindowText(m_ahRadioButtons[nNum]);
 } // end of wxRadioBox::GetString
 
 // For single selection items only
 wxString wxRadioBox::GetStringSelection() const
 {
-    wxString                        sResult;
-    int                             nSel = GetSelection();
+    wxString sResult;
+    int nSel = GetSelection();
 
 
-    if (nSel > -1)
+    if (nSel != wxNOT_FOUND)
         sResult = GetString(nSel);
         sResult = GetString(nSel);
+
     return sResult;
 } // end of wxRadioBox::GetStringSelection
 
     return sResult;
 } // end of wxRadioBox::GetStringSelection
 
@@ -855,8 +641,8 @@ wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const
     //
     // And also wide enough for its label
     //
     //
     // And also wide enough for its label
     //
-    wxString                        sStr = wxGetWindowText(GetHwnd());
-    if (!sStr.IsEmpty())
+    wxString sStr = wxGetWindowText(GetHwnd());
+    if (!sStr.empty())
     {
         GetTextExtent( sStr
                       ,&nWidthLabel
     {
         GetTextExtent( sStr
                       ,&nWidthLabel
@@ -904,8 +690,7 @@ bool wxRadioBox::OS2Command( WXUINT uCmd,
         if (wId == GetId())
             return true;
 
         if (wId == GetId())
             return true;
 
-
-        for (int i = 0; i < m_nNoItems; i++)
+        for (unsigned int i = 0; i < m_nNoItems; i++)
         {
             if (wId == wxGetWindowId(m_ahRadioButtons[i]))
             {
         {
             if (wId == wxGetWindowId(m_ahRadioButtons[i]))
             {
@@ -933,9 +718,10 @@ bool wxRadioBox::OS2Command( WXUINT uCmd,
 
 void wxRadioBox::SendNotificationEvent()
 {
 
 void wxRadioBox::SendNotificationEvent()
 {
-    wxCommandEvent                  vEvent( wxEVT_COMMAND_RADIOBOX_SELECTED
-                                           ,m_windowId
-                                          );
+    wxCommandEvent vEvent(
+                       wxEVT_COMMAND_RADIOBOX_SELECTED,
+                       m_windowId
+                   );
 
     vEvent.SetInt( m_nSelectedButton );
     vEvent.SetString( GetString(m_nSelectedButton) );
 
     vEvent.SetInt( m_nSelectedButton );
     vEvent.SetString( GetString(m_nSelectedButton) );
@@ -954,9 +740,7 @@ void wxRadioBox::SetFocus()
     }
 } // end of wxRadioBox::SetFocus
 
     }
 } // end of wxRadioBox::SetFocus
 
-bool wxRadioBox::SetFont(
-  const wxFont&                     rFont
-)
+bool wxRadioBox::SetFont(const wxFont& rFont)
 {
     if (!wxControl::SetFont(rFont))
     {
 {
     if (!wxControl::SetFont(rFont))
     {
@@ -968,13 +752,11 @@ bool wxRadioBox::SetFont(
     //
     // Also set the font of our radio buttons
     //
     //
     // Also set the font of our radio buttons
     //
-    for (int n = 0; n < (int)m_nNoItems; n++)
+    for (unsigned int n = 0; n < m_nNoItems; n++)
     {
     {
-        HWND                        hWndBtn = (HWND)m_ahRadioButtons[n];
+        HWND hWndBtn = (HWND)m_ahRadioButtons[n];
 
 
-        wxOS2SetFont( hWndBtn
-                     ,rFont
-                    );
+        wxOS2SetFont( hWndBtn, rFont );
         ::WinInvalidateRect(hWndBtn, NULL, FALSE);
     }
     return true;
         ::WinInvalidateRect(hWndBtn, NULL, FALSE);
     }
     return true;
@@ -994,15 +776,12 @@ void wxRadioBox::SetSelection(
     m_nSelectedButton = nNum;
 } // end of wxRadioBox::SetSelection
 
     m_nSelectedButton = nNum;
 } // end of wxRadioBox::SetSelection
 
-void wxRadioBox::SetString(
-  int                               nItem
-, const wxString&                   rsLabel
-)
+void wxRadioBox::SetString(unsigned int nItem, const wxString& rsLabel)
 {
     wxCHECK_RET( IsValid(nItem), wxT("invalid radiobox index") );
 
     m_pnRadioWidth[nItem] = m_pnRadioHeight[nItem] = -1;
 {
     wxCHECK_RET( IsValid(nItem), wxT("invalid radiobox index") );
 
     m_pnRadioWidth[nItem] = m_pnRadioHeight[nItem] = -1;
-    ::WinSetWindowText((HWND)m_ahRadioButtons[nItem], (PSZ)rsLabel.c_str());
+    ::WinSetWindowText((HWND)m_ahRadioButtons[nItem], rsLabel.c_str());
 } // end of wxRadioBox::SetString
 
 bool wxRadioBox::SetStringSelection(const wxString& rsStr)
 } // end of wxRadioBox::SetString
 
 bool wxRadioBox::SetStringSelection(const wxString& rsStr)
@@ -1018,14 +797,12 @@ bool wxRadioBox::SetStringSelection(const wxString& rsStr)
         return false;
 } // end of wxRadioBox::SetStringSelection
 
         return false;
 } // end of wxRadioBox::SetStringSelection
 
-bool wxRadioBox::Show(
-  bool                              bShow
-)
+bool wxRadioBox::Show(bool bShow)
 {
     if (!wxControl::Show(bShow))
         return false;
 
 {
     if (!wxControl::Show(bShow))
         return false;
 
-    for (int i = 0; i < m_nNoItems; i++)
+    for (unsigned int i = 0; i < m_nNoItems; i++)
     {
         ::WinShowWindow((HWND)m_ahRadioButtons[i], (BOOL)bShow);
     }
     {
         ::WinShowWindow((HWND)m_ahRadioButtons[i], (BOOL)bShow);
     }
@@ -1033,10 +810,7 @@ bool wxRadioBox::Show(
 } // end of wxRadioBox::Show
 
 // Show a specific button
 } // end of wxRadioBox::Show
 
 // Show a specific button
-bool wxRadioBox::Show(
-  int                               nItem
-, bool                              bShow
-)
+bool wxRadioBox::Show(unsigned int nItem, bool bShow)
 {
     wxCHECK_MSG( IsValid(nItem), false,
                  wxT("invalid item in wxRadioBox::Show()") );
 {
     wxCHECK_MSG( IsValid(nItem), false,
                  wxT("invalid item in wxRadioBox::Show()") );
@@ -1096,11 +870,11 @@ MRESULT wxRadioBtnWndProc(
                         switch(uVk)
                         {
                             case VK_LEFT:
                         switch(uVk)
                         {
                             case VK_LEFT:
-                                eDir = wxDOWN;
+                                eDir = wxLEFT;
                                 break;
 
                             case VK_RIGHT:
                                 break;
 
                             case VK_RIGHT:
-                                eDir = wxDOWN;
+                                eDir = wxRIGHT;
                                 break;
 
                             case VK_DOWN:
                                 break;
 
                             case VK_DOWN:
@@ -1163,3 +937,5 @@ MRESULT EXPENTRY wxRadioBoxWndProc( HWND hWnd,
                                (MPARAM)lParam )
            );
 } // end of wxRadioBoxWndProc
                                (MPARAM)lParam )
            );
 } // end of wxRadioBoxWndProc
+
+#endif // wxUSE_RADIOBOX