X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/baf34314451302852746f3271f5eb4ec94015f64..5fc01d1326a34223746546326a7f616df8bfa991:/src/mac/carbon/radiobox.cpp diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index fbf840fc8d..83bd0a1f78 100644 --- a/src/mac/carbon/radiobox.cpp +++ b/src/mac/carbon/radiobox.cpp @@ -19,6 +19,7 @@ //------------------------------------------------------------------------------------- #include "wx/defs.h" +#include "wx/arrstr.h" #include "wx/radiobox.h" #include "wx/radiobut.h" @@ -28,9 +29,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxRadioBox, wxControl) #endif -#pragma mark - -#pragma mark ### Constructors & destructor ### - //------------------------------------------------------------------------------------- // ¥ wxRadioBox() //------------------------------------------------------------------------------------- @@ -77,6 +75,8 @@ wxRadioBox::wxRadioBox() wxRadioBox::~wxRadioBox() { + m_isBeingDeleted = TRUE; + wxRadioButton *next,*current; current=m_radioButtonCycle->NextInCycle(); @@ -94,12 +94,29 @@ wxRadioBox::~wxRadioBox() //------------------------------------------------------------------------------------- // Create the radiobox for two-step construction +bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, + const wxPoint& pos, const wxSize& size, + const wxArrayString& choices, + int majorDim, long style, + const wxValidator& val, const wxString& name) +{ + wxCArrayString chs(choices); + + return Create(parent, id, label, pos, size, chs.GetCount(), + chs.GetStrings(), majorDim, style, val, name); +} + bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, const wxPoint& pos, const wxSize& size, int n, const wxString choices[], int majorDim, long style, const wxValidator& val, const wxString& name) { + m_macIsUserPane = FALSE ; + + if ( !wxControl::Create(parent, id, pos, size, style, val, name) ) + return false; + int i; m_noItems = n; @@ -112,33 +129,40 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, m_majorDim = majorDim ; - Rect bounds ; - Str255 title ; - - MacPreControlCreate( parent , id , wxStripMenuCodes(label) , pos , size ,style, val , name , &bounds , title ) ; - - m_macControl = ::NewControl( MAC_WXHWND(parent->MacGetRootWindow()) , &bounds , title , false , 0 , 0 , 1, + m_label = label ; + + Rect bounds = wxMacGetBoundsForControl( this , pos , size ) ; + if( bounds.right <= bounds.left ) + bounds.right = bounds.left + 100 ; + if ( bounds.bottom <= bounds.top ) + bounds.bottom = bounds.top + 100 ; + + m_macControl = (WXWidget) ::NewControl( MAC_WXHWND(parent->MacGetTopLevelWindowRef()) , &bounds , "\p" , true , 0 , 0 , 1, kControlGroupBoxTextTitleProc , (long) this ) ; for (i = 0; i < n; i++) { - wxRadioButton *radBtn = new wxRadioButton(this, NewControlId(), wxStripMenuCodes(choices[i]),wxPoint(5,20*i+10), - wxDefaultSize , i == 0 ? wxRB_GROUP : 0 ) ; + wxRadioButton *radBtn = new wxRadioButton + ( + this, + wxID_ANY, + wxStripMenuCodes(choices[i]), + wxPoint(5,20*i+10), + wxDefaultSize, + i == 0 ? wxRB_GROUP : 0 + ); if ( i == 0 ) m_radioButtonCycle = radBtn ; // m_radioButtonCycle=radBtn->AddInCycle(m_radioButtonCycle); } SetSelection(0); - MacPostControlCreate() ; + MacPostControlCreate(pos,size) ; return TRUE; } -#pragma mark - -#pragma mark ### Specific functions (reference v2) ### - //------------------------------------------------------------------------------------- // ¥ Enable(bool) //------------------------------------------------------------------------------------- @@ -337,9 +361,6 @@ void wxRadioBox::Show(int item, bool show) current->Show(show); } -#pragma mark - -#pragma mark ### Other external functions ### - //------------------------------------------------------------------------------------- // ¥ Command //------------------------------------------------------------------------------------- @@ -371,9 +392,6 @@ void wxRadioBox::SetFocus() } -#pragma mark - -#pragma mark ### Internal functions ### - //------------------------------------------------------------------------------------- // ¥ DoSetSize //------------------------------------------------------------------------------------- @@ -408,8 +426,8 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) int eachWidth[128],eachHeight[128]; int totWidth,totHeight; - SetFont(GetParent()->GetFont()); GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight); + charWidth/=52; maxWidth=-1; @@ -423,14 +441,16 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags) if (maxHeightGetFont(); GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight, NULL, NULL, &font); + charWidth /= 52; maxWidth = -1; @@ -499,15 +521,19 @@ wxSize wxRadioBox::DoGetBestSize() const for (int i = 0 ; i < m_noItems; i++) { - GetTextExtent(GetString(i), &eachWidth, &eachHeight); + GetTextExtent(GetString(i), &eachWidth, &eachHeight,NULL, NULL, &font); eachWidth = (int)(eachWidth + RADIO_SIZE) ; eachHeight = (int)((3 * eachHeight) / 2); if (maxWidth < eachWidth) maxWidth = eachWidth; if (maxHeight < eachHeight) maxHeight = eachHeight; } - totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ; - totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth; + totHeight = GetRowCount() * (maxHeight ) ; + totWidth = GetColumnCount() * (maxWidth + charWidth) ; + + wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ; + totWidth = sz.x ; + totHeight = sz.y ; // handle radio box title as well GetTextExtent(GetTitle(), &eachWidth, NULL);