+ // Attempt to have a look coherent with other platforms: We compute the
+ // biggest toggle dim, then we align all items according this value.
+ wxSize maxSize = GetMaxButtonSize();
+ int maxWidth = maxSize.x,
+ maxHeight = maxSize.y;
+
+ wxSize totSize = GetTotalButtonSize(maxSize);
+ int totWidth = totSize.x,
+ totHeight = totSize.y;
+
+ // only change our width/height if asked for
+ if ( width == wxDefaultCoord )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_WIDTH )
+ width = totWidth;
+ else
+ width = widthOld;
+ }
+
+ if ( height == wxDefaultCoord )
+ {
+ if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
+ height = totHeight;
+ else
+ height = heightOld;
+ }
+
+ DoMoveWindow(xx, yy, width, height);
+
+ // 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 GetMajorDim() is the number of columns while
+ // wxRA_SPECIFY_ROWS means that the buttons are arranged top to bottom and
+ // GetMajorDim() is the number of rows.
+
+ x_offset += cx1;
+ y_offset += cy1;
+
+ // Add extra space under the label, if it exists.
+ if (!wxControl::GetLabel().empty())
+ y_offset += cy1/2;
+
+ int startX = x_offset;
+ int startY = y_offset;
+
+ const unsigned int count = GetCount();
+ for (unsigned int i = 0; i < count; 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 isLastInTheRow;
+ 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
+ unsigned int n = i + 1;
+ isLastInTheRow = ((n % GetMajorDim()) == 0) || (n == count);
+ }
+ else // wxRA_SPECIFY_ROWS
+ {
+ // item is the last in the row if it is in the last columns
+ isLastInTheRow = i >= (count/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
+ y_offset = startY;
+ x_offset += maxWidth + cx1;
+ }
+ else // start of new row
+ {
+ x_offset = startX;
+ y_offset += maxHeight;
+ if (m_radioWidth[0]>0)
+ y_offset += cy1/2;
+ }
+ }
+
+ int widthBtn;
+ if ( isLastInTheRow )
+ {
+ // make the button go to the end of radio box
+ widthBtn = startX + width - x_offset - 2*cx1;
+ if ( widthBtn < maxWidth )
+ widthBtn = maxWidth;
+ }
+ else
+ {
+ // normal button, always of the same size
+ widthBtn = maxWidth;
+ }
+
+ // 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)
+ DoMoveSibling((*m_radioButtons)[i], x_offset, y_offset, widthBtn, maxHeight);
+
+ // where do we put the next button?
+ if ( m_windowStyle & wxRA_SPECIFY_ROWS )
+ {
+ // below this one
+ y_offset += maxHeight;
+ if (m_radioWidth[0]>0)
+ y_offset += cy1/2;
+ }
+ else
+ {
+ // to the right of this one
+ x_offset += widthBtn + cx1;
+ }
+ }