+ vColour.Set(wxString("BLACK"));
+ lColor = (LONG)vColour.GetPixel();
+ m_nSelectedButton = -1;
+ m_nNoItems = nNum;
+
+ m_nMajorDim = nMajorDim == 0 ? nNum : nMajorDim;
+ m_nNoRowsOrCols = nMajorDim;
+
+ //
+ // Common initialization
+ //
+ if (!OS2CreateControl( pParent
+ ,vId
+ ,rPos
+ ,rSize
+ ,lStyle
+#if wxUSE_VALIDATORS
+ ,rVal
+#endif
+ ,rsName
+ ))
+
+
+
+
+ if (!OS2CreateControl( "STATIC"
+ ,SS_GROUPBOX | WS_GROUP
+ ,rPos
+ ,rSize
+ ,rsTitle
+ ))
+
+#if RADIOBTN_PARENT_IS_RADIOBOX
+ HWND hWndParent = GetHwnd();
+#else
+ HWND hWndParent = GetHwndOf(pParent);
+#endif
+ HFONT hFont;
+
+ //
+ // Some radio boxes test consecutive id.
+ //
+ (void)NewControlId();
+ m_ahRadioButtons = new WXHWND[nNum];
+ m_pnRadioWidth = new int[nNum];
+ m_pnRadioHeight = new int[nNum];
+
+ if (rFont.Ok())
+ {
+ hFont = rFont.GetResourceHandle();
+ }
+
+ for (int i = 0; i < nNum; i++)
+ {
+ m_pnRadioWidth[i] = m_pnRadioHeight[i] = -1;
+
+ long lStyleBtn = BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE;
+ int nNewId = NewControlId();
+
+ if (i == 0 && lStyle == 0)
+ lStyleBtn |= WS_GROUP;
+
+ HWND hWndBtn = (WXHWND)::WinCreateWindow ( GetHwndOf(pParent)
+ ,WC_BUTTON
+ ,asChoices[i]
+ ,lStyleBtn
+ ,0, 0, 0, 0
+ ,GetWinHwnd(pParent)
+ ,HWND_TOP
+ ,(HMENU)nNewId
+ ,NULL
+ ,NULL
+ );
+ ::WinSetPresParam( hWndBtn
+ ,PP_FOREGROUNDCOLOR
+ ,sizeof(LONG)
+ ,(PVOID)&lColor
+ );
+ if (!hWndBtn)
+ {
+ return FALSE;
+ }
+ m_ahRadioButtons[i] = (WXHWND)hWndBtn;
+ SubclassRadioButton((WXHWND)hWndBtn);
+ wxOS2SetFont( hWndBtn
+ ,rFont
+ );
+ ::WinSetWindowULong(hWndBtn, QWL_USER, (ULONG)this);
+ m_aSubControls.Add(nNewId);
+ }
+
+ //
+ // 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
+ );
+ SetFont(*wxSMALL_FONT);
+ ::WinSetPresParam( m_hWnd
+ ,PP_FOREGROUNDCOLOR
+ ,sizeof(LONG)
+ ,(PVOID)&lColor
+ );
+ SetSelection(0);
+ SetSize( rPos.x
+ ,rPos.y
+ ,rSize.x
+ ,rSize.y
+ );
+ return TRUE;
+} // end of wxRadioBox::Create
+
+wxSize wxRadioBox::DoGetBestSize() const
+{
+ return (GetTotalButtonSize(GetMaxButtonSize()));
+} // end of WinGuiBase_CRadioBox::DoGetBestSize
+
+void wxRadioBox::DoSetSize(
+ int nX
+, int nY
+, int nWidth
+, int nHeight
+, int nSizeFlags
+)
+{
+ 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;
+#endif
+ int nCx1;
+ int nCy1;
+ wxSize vMaxSize = GetMaxButtonSize();
+ int nMaxWidth;
+ int nMaxHeight;
+ wxSize vTotSize;
+ int nTotWidth;
+ int nTotHeight;
+ int nStartX;
+ int nStartY;
+
+ m_nSizeFlags = nSizeFlags;
+ GetPosition( &nCurrentX
+ ,&nCurrentY
+ );
+ GetSize( &nWidthOld
+ ,&nHeightOld
+ );
+
+ if (nX == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ nXx = nCurrentX;
+ if (nY == -1 && !(nSizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ nYy = nCurrentY;
+
+
+ wxGetCharSize( m_hWnd
+ ,&nCx1
+ ,&nCy1
+ ,&GetFont()
+ );
+
+ //
+ // Attempt to have a look coherent with other platforms: We compute the
+ // biggest toggle dim, then we align all items according this value.
+ //
+ vMaxSize = GetMaxButtonSize();
+ nMaxWidth = vMaxSize.x;
+ nMaxHeight = vMaxSize.y;
+
+ vTotSize = GetTotalButtonSize(vMaxSize);
+ nTotWidth = vTotSize.x;
+ nTotHeight = vTotSize.y;
+
+ //
+ // Only change our width/height if asked for
+ //
+ if (nWidth == -1)
+ {
+ if (nSizeFlags & wxSIZE_AUTO_WIDTH )
+ nWidth = nTotWidth;
+ else
+ nWidth = nWidthOld;
+ }
+
+ if (nHeight == -1)
+ {
+ if (nSizeFlags & wxSIZE_AUTO_HEIGHT)
+ nHeight = nTotHeight;
+ else
+ nHeight = nHeightOld;
+ }
+
+ wxWindowOS2* pParent = (wxWindowOS2*)GetParent();
+
+ if (pParent)
+ {
+ nYy = pParent->GetClientSize().y - (nYy + nHeight);
+ nYOffset = nYy + nHeight;
+ }
+ else
+ {
+ RECTL vRect;
+
+ ::WinQueryWindowRect(HWND_DESKTOP, &vRect);
+ nYy = vRect.yTop - (nYy + nHeight);
+ }
+ ::WinSetWindowPos( GetHwnd()
+ ,HWND_TOP
+ ,(LONG)nXx
+ ,(LONG)nYy
+ ,(LONG)nWidth
+ ,(LONG)nHeight
+ ,SWP_ZORDER | SWP_SIZE | SWP_MOVE | SWP_SHOW
+ );
+
+ //
+ // Now position all the buttons: the current button will be put at
+ // wxPoint(x_offset, y_offset) and the new row/column will start at
+ // startX/startY. The size of all buttons will be the same wxSize(maxWidth,
+ // maxHeight) except for the buttons in the last column which should extend
+ // to the right border of radiobox and thus can be wider than this.
+ //
+ // Also, remember that wxRA_SPECIFY_COLS means that we arrange buttons in
+ // left to right order and m_majorDim is the number of columns while
+ // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and
+ // m_majorDim is the number of rows.
+ //
+ 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 % m_nMajorDim) == 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;
+ }
+
+ //
+ // Is this the start of new row/column?
+ //
+ if (i && (i % m_nMajorDim == 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 beinting 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::DoSetSize
+
+void wxRadioBox::Enable(
+ int nItem
+, bool bEnable
+)