//-------------------------------------------------------------------------------------
#include "wx/defs.h"
+#include "wx/arrstr.h"
#include "wx/radiobox.h"
#include "wx/radiobut.h"
//-------------------------------------------------------------------------------------
// 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;
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++)
}
SetSelection(0);
- MacPostControlCreate() ;
+ MacPostControlCreate(pos,size) ;
return TRUE;
}
int eachWidth[128],eachHeight[128];
int totWidth,totHeight;
- SetFont(GetParent()->GetFont());
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), &charWidth, &charHeight);
+
charWidth/=52;
maxWidth=-1;
if (maxHeight<eachHeight[i]) maxHeight = eachHeight[i];
}
- totHeight = GetRowCount() * (maxHeight + charHeight/2) + charHeight ;
- totWidth = GetColumnCount() * (maxWidth + charWidth) + charWidth;
+ totHeight = GetRowCount() * ( maxHeight ) ;
+ totWidth = GetColumnCount() * (maxWidth + charWidth) ;
+
+ wxSize sz = DoGetSizeFromClientSize( wxSize( totWidth , totHeight ) ) ;
// only change our width/height if asked for
if ( width == -1 )
{
if ( sizeFlags & wxSIZE_AUTO_WIDTH )
- width = totWidth ;
+ width = sz.x ;
else
width = widthOld;
}
if ( height == -1 )
{
if ( sizeFlags & wxSIZE_AUTO_HEIGHT )
- height = totHeight ;
+ height = sz.y ;
else
height = heightOld;
}
int x_start,y_start;
- x_start = charWidth;
- y_start = 15 ;
+ x_start = 0;
+ y_start = 0 ;
+
x_offset = x_start;
y_offset = y_start;
wxFont font = GetParent()->GetFont();
GetTextExtent(wxT("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"),
&charWidth, &charHeight, NULL, NULL, &font);
+
charWidth /= 52;
maxWidth = -1;
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);