X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5d8fbe213ca853dba80fb5412fa13bda16f283b5..56d061c578db49bb2dc98ccf34559d3027982a3b:/src/mac/carbon/radiobox.cpp?ds=sidebyside diff --git a/src/mac/carbon/radiobox.cpp b/src/mac/carbon/radiobox.cpp index 9ef60f5594..cf279d567b 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" @@ -93,12 +94,26 @@ 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; @@ -114,13 +129,16 @@ 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, - kControlGroupBoxTextTitleProc , (long) this ) ; + 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 ; + + verify_noerr(CreateGroupBoxControl(MAC_WXHWND(parent->MacGetTopLevelWindowRef()),&bounds, CFSTR("") , + true /*primary*/ , (ControlRef*)&m_macControl ) ) ; for (i = 0; i < n; i++) { @@ -139,7 +157,7 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, } SetSelection(0); - MacPostControlCreate() ; + MacPostControlCreate(pos,size) ; return TRUE; } @@ -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 (maxHeight= 0x1030 ) - { - //need to add a few more pixels for the top border on panther - y_start = y_start + 5; //how many exactly should this be to meet the HIG? - } + x_start = 0; + y_start = 0 ; + x_offset = x_start; y_offset = y_start; @@ -497,6 +513,7 @@ wxSize wxRadioBox::DoGetBestSize() const wxFont font = GetParent()->GetFont(); GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight, NULL, NULL, &font); + charWidth /= 52; maxWidth = -1; @@ -504,21 +521,20 @@ 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 ; - if ( UMAGetSystemVersion() >= 0x1030 ) - { - //need to add a few more pixels for the static boxborder on panther - totHeight = totHeight + 10; //how many exactly should this be to meet the HIG? - } // handle radio box title as well GetTextExtent(GetTitle(), &eachWidth, NULL); eachWidth = (int)(eachWidth + RADIO_SIZE) + 3 * charWidth ;