X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/ae255e294844a848463646f3ed6b9921f37f36ee..50f12a63130b81796ea531c59af97f0544cf158d:/src/osx/radiobox_osx.cpp diff --git a/src/osx/radiobox_osx.cpp b/src/osx/radiobox_osx.cpp index 3b1b220205..e4ebe931be 100644 --- a/src/osx/radiobox_osx.cpp +++ b/src/osx/radiobox_osx.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/radiobox.cpp +// Name: src/osx/radiobox_osx.cpp // Purpose: wxRadioBox // Author: Stefan Csomor // Modified by: JS Lair (99/11/15) first implementation @@ -38,7 +38,7 @@ void wxRadioBox::OnRadioButton( wxCommandEvent &outer ) { if ( outer.IsChecked() ) { - wxCommandEvent event( wxEVT_COMMAND_RADIOBOX_SELECTED, m_windowId ); + wxCommandEvent event( wxEVT_RADIOBOX, m_windowId ); int i = GetSelection() ; event.SetInt(i); event.SetString(GetString(i)); @@ -97,15 +97,14 @@ bool wxRadioBox::Create( wxWindow *parent, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name ) -{ - m_macIsUserPane = false ; - +{ + DontCreatePeer(); + if ( !wxControl::Create( parent, id, pos, size, style, val, name ) ) return false; - int i; - - m_noItems = (unsigned int)n; + // during construction we must keep this at 0, otherwise GetBestSize fails + m_noItems = 0; m_noRowsOrCols = majorDim; m_radioButtonCycle = NULL; @@ -113,9 +112,9 @@ bool wxRadioBox::Create( wxWindow *parent, m_labelOrig = m_label = label; - m_peer = wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() ); + SetPeer(wxWidgetImpl::CreateGroupBox( this, parent, id, label, pos, size, style, GetExtraStyle() )); - for (i = 0; i < n; i++) + for (int i = 0; i < n; i++) { wxRadioButton *radBtn = new wxRadioButton( this, @@ -130,7 +129,13 @@ bool wxRadioBox::Create( wxWindow *parent, // m_radioButtonCycle = radBtn->AddInCycle( m_radioButtonCycle ); } + // as all radiobuttons have been set-up, set the correct dimensions + m_noItems = (unsigned int)n; + SetMajorDim( majorDim == 0 ? n : majorDim, style ); + SetSelection( 0 ); + InvalidateBestSize(); + SetInitialSize( size ); MacPostControlCreate( pos, size ); return true; @@ -260,7 +265,7 @@ void wxRadioBox::SetString(unsigned int item,const wxString& label) } // Sets a button by passing the desired position. This does not cause -// wxEVT_COMMAND_RADIOBOX_SELECTED event to get emitted +// wxEVT_RADIOBOX event to get emitted // void wxRadioBox::SetSelection(int item) { @@ -407,7 +412,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) wxSize bestSizeRadio ; if ( m_radioButtonCycle ) bestSizeRadio = m_radioButtonCycle->GetBestSize(); - + for (unsigned int i = 0 ; i < m_noItems; i++) { GetTextExtent(GetString(i), &eachWidth[i], &eachHeight[i] ); @@ -421,10 +426,10 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) - int space = 3; + int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; - + totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); @@ -480,7 +485,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) current = current->NextInCycle(); if (m_windowStyle & wxRA_SPECIFY_ROWS) - y_offset += maxHeight + space; + y_offset += maxHeight + space; else x_offset += maxWidth + charWidth; } @@ -519,10 +524,10 @@ wxSize wxRadioBox::DoGetBestSize() const } // according to HIG (official space - 3 Pixels Diff between Frame and Layout size) - int space = 3; + int space = 3; if ( GetWindowVariant() == wxWINDOW_VARIANT_MINI ) space = 2; - + totHeight = GetRowCount() * maxHeight + (GetRowCount() - 1) * space; totWidth = GetColumnCount() * (maxWidth + charWidth); @@ -548,7 +553,7 @@ bool wxRadioBox::SetFont(const wxFont& font) bool retval = wxWindowBase::SetFont( font ); // dont' update the native control, it has its own small font - + // should we iterate over the children ? return retval;