]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/radiobox.cpp
Add comments about the pango crashes on Solaris 10
[wxWidgets.git] / src / os2 / radiobox.cpp
index af010f9576a6c27f29031397a56818232df0878a..019dae4ab02b28f231595eb8cc7dd50ddb5debc5 100644 (file)
@@ -68,7 +68,6 @@ wxRadioBox::wxRadioBox()
     m_nNoItems = 0;
     m_nNoRowsOrCols = 0;
     m_ahRadioButtons = NULL;
-    m_nMajorDim = 0;
     m_pnRadioWidth = NULL;
     m_pnRadioHeight = NULL;
 } // end of wxRadioBox::wxRadioBox
@@ -139,20 +138,20 @@ void wxRadioBox::AdjustButtons( int nX,
             //
             int                     n = i + 1;
 
-            bIsLastInTheRow = ((n % m_nMajorDim) == 0) || (n == m_nNoItems);
+            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/m_nMajorDim) * m_nMajorDim;
+            bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim();
         }
 
         //
         // Is this the start of new row/column?
         //
-        if (i && (i % m_nMajorDim == 0))
+        if (i && (i % GetMajorDim() == 0))
         {
             if (m_windowStyle & wxRA_SPECIFY_ROWS)
             {
@@ -195,7 +194,7 @@ void wxRadioBox::AdjustButtons( int nX,
         // 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 beYInt32ing to any radiobutton)
+        // radiobox part not belonging to any radiobutton)
         //
         ::WinSetWindowPos( (HWND)m_ahRadioButtons[i]
                           ,HWND_TOP
@@ -291,9 +290,6 @@ bool wxRadioBox::Create(
     m_nSelectedButton = -1;
     m_nNoItems = 0;
 
-    m_nMajorDim     = nMajorDim == 0 ? nNum : nMajorDim;
-    m_nNoRowsOrCols = nMajorDim;
-
     //
     // Common initialization
     //
@@ -317,9 +313,15 @@ bool wxRadioBox::Create(
     wxAssociateWinWithHandle(m_hWnd, this);
 
     //
-    // Some radio boxes test consecutive id.
+    // Now we can set m_nNoItems and let SetMajorDim set m_numCols/m_numRows
     //
     m_nNoItems = nNum;
+    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];
@@ -337,7 +339,7 @@ bool wxRadioBox::Create(
 
         HWND                        hWndBtn = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent)
                                                                          ,WC_BUTTON
-                                                                         ,(PSZ)asChoices[i].c_str()
+                                                                         ,::wxPMTextToLabel(asChoices[i])
                                                                          ,lStyleBtn
                                                                          ,0, 0, 0, 0
                                                                          ,GetWinHwnd(pParent)
@@ -376,16 +378,16 @@ bool wxRadioBox::Create(
     //
     // Create a dummy radio control to end the group.
     //
-    (void)::WinCreateWindow ( GetHwndOf(pParent)
-                             ,WC_BUTTON
-                             ,""
-                             ,WS_GROUP | BS_AUTORADIOBUTTON
-                             ,0, 0, 0, 0
-                             ,GetWinHwnd(pParent)
-                             ,HWND_TOP
-                             ,(HMENU)NewControlId()
-                             ,NULL
-                             ,NULL
+    (void)::WinCreateWindow ( GetHwndOf(pParent),
+                              WC_BUTTON,
+                              "",
+                              WS_GROUP | BS_AUTORADIOBUTTON,
+                              0, 0, 0, 0,
+                              GetWinHwnd(pParent),
+                              HWND_TOP,
+                              (HMENU)NewControlId(),
+                              NULL,
+                              NULL
                             );
     SetFont(*wxSMALL_FONT);
     fnWndProcRadioBox = (WXFARPROC)::WinSubclassWindow( GetHwnd()
@@ -578,20 +580,20 @@ void wxRadioBox::DoSetSize(
             //
             int                  n = i + 1;
 
-            bIsLastInTheRow = ((n % m_nMajorDim) == 0) || (n == m_nNoItems);
+            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/m_nMajorDim) * m_nMajorDim;
+            bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim();
         }
 
         //
         // Is this the start of new row/column?
         //
-        if (i && (i % m_nMajorDim == 0))
+        if (i && (i % GetMajorDim() == 0))
         {
             if (m_windowStyle & wxRA_SPECIFY_ROWS)
             {
@@ -634,7 +636,7 @@ void wxRadioBox::DoSetSize(
         // 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 beinting to any radiobutton)
+        // radiobox part not belonging to any radiobutton)
         //
         ::WinSetWindowPos( (HWND)m_ahRadioButtons[i]
                           ,HWND_TOP
@@ -686,11 +688,6 @@ bool wxRadioBox::Enable(
     return true;
 } // end of wxRadioBox::Enable
 
-int wxRadioBox::GetColumnCount() const
-{
-    return GetNumHor();
-} // end of wxRadioBox::GetColumnCount
-
 int wxRadioBox::GetCount() const
 {
     return m_nNoItems;
@@ -742,32 +739,8 @@ wxSize wxRadioBox::GetMaxButtonSize() const
     return maxsize;
 } // end of wxRadioBox::GetMaxButtonSize
 
-int wxRadioBox::GetNumHor() const
-{
-    if ( m_windowStyle & wxRA_SPECIFY_ROWS )
-    {
-        return (m_nNoItems + m_nMajorDim - 1)/m_nMajorDim;
-    }
-    else
-    {
-        return m_nMajorDim;
-    }
-} // end of wxRadioBox::GetNumHor
-
-int wxRadioBox::GetNumVer() const
-{
-    if ( m_windowStyle & wxRA_SPECIFY_ROWS )
-    {
-        return m_nMajorDim;
-    }
-    else
-    {
-        return (m_nNoItems + m_nMajorDim - 1)/m_nMajorDim;
-    }
-} // end of wxRadioBox::GetNumVer
-
 void wxRadioBox::GetPosition( int* pnX,
-                              int* WXUNUSED(pnY) ) const
+                              int* pnY ) const
 {
     wxWindowOS2*                    pParent = GetParent();
     RECT                            vRect = { -1, -1, -1, -1 };
@@ -809,25 +782,19 @@ void wxRadioBox::GetPosition( int* pnX,
         vPoint.x = vPt.x;
         vPoint.y = vPt.y;
     }
-    *pnX = vPoint.x;
-    *pnX = vPoint.y;
+    if (pnX)
+        *pnX = vPoint.x;
+    if (pnY)
+        *pnY = vPoint.y;
 } // end of wxRadioBox::GetPosition
 
-int wxRadioBox::GetRowCount() const
-{
-    return GetNumVer();
-} // end of wxRadioBox::GetRowCount
-
 // Get single selection, for single choice list items
 int wxRadioBox::GetSelection() const
 {
     return m_nSelectedButton;
 } // end of wxRadioBox::GetSelection
 
-void wxRadioBox::GetSize(
-  int*                              pnWidth
-, int*                              pnHeight
-) const
+void wxRadioBox::GetSize( int* pnWidth, int* pnHeight ) const
 {
     RECT                            vRect;
     int                             i;
@@ -876,26 +843,27 @@ wxSize wxRadioBox::GetTotalButtonSize( const wxSize& rSizeBtn ) const
 {
     int    nCx1;
     int    nCy1;
-    int    nExtraHeight;
     int    nHeight;
     int    nWidth;
-    int    nWidthLabel;
-    wxFont vFont = GetFont();
-
-    wxGetCharSize( m_hWnd, &nCx1, &nCy1, &vFont );
-    nExtraHeight = nCy1;
+    int    nWidthLabel = 0;
 
-    nHeight = GetNumVer() * rSizeBtn.y + (2 * nCy1);
-    nWidth  = GetNumHor() * (rSizeBtn.x + nCx1) + nCx1;
+    nCx1 = GetCharWidth();
+    nCy1 = GetCharHeight();
+    nHeight = GetRowCount() * rSizeBtn.y + (2 * nCy1);
+    nWidth  = GetColumnCount() * (rSizeBtn.x + nCx1) + nCx1;
 
     //
     // And also wide enough for its label
     //
-    GetTextExtent( GetTitle()
-                  ,&nWidthLabel
-                  ,NULL
-                 );
-    nWidthLabel += RADIO_SIZE;
+    wxString                        sStr = wxGetWindowText(GetHwnd());
+    if (!sStr.IsEmpty())
+    {
+        GetTextExtent( sStr
+                      ,&nWidthLabel
+                      ,NULL
+                     );
+        nWidthLabel += 2*nCx1;
+    }
     if (nWidthLabel > nWidth)
         nWidth = nWidthLabel;
 
@@ -1184,17 +1152,14 @@ MRESULT wxRadioBtnWndProc(
                             );
 } // end of wxRadioBtnWndProc
 
-MRESULT EXPENTRY wxRadioBoxWndProc(
-  HWND                              hWnd
-, UINT                              uMessage
-, MPARAM                            wParam
-, MPARAM                            lParam
-)
+MRESULT EXPENTRY wxRadioBoxWndProc( HWND hWnd,
+                                    UINT uMessage,
+                                    MPARAM wParam,
+                                    MPARAM lParam )
 {
-    return (fnWndProcRadioBox( hWnd
-                              ,(ULONG)uMessage
-                              ,(MPARAM)wParam
-                              ,(MPARAM)lParam
-                             )
+    return (fnWndProcRadioBox( hWnd,
+                               (ULONG)uMessage,
+                               (MPARAM)wParam,
+                               (MPARAM)lParam )
            );
 } // end of wxRadioBoxWndProc