\docparam{string}{The string to find.}
+\membersection{wxRadioBox::GetColumnCount}\label{wxradioboxgetcolumncount}
+
+\constfunc{int}{GetColumnCount}{\void}
+
+Returns the number of columns in the radiobox.
+
+
\membersection{wxRadioBox::GetCount}\label{wxradioboxgetcount}
\constfunc{int}{GetCount}{\void}
}
+\membersection{wxRadioBox::GetRowCount}\label{wxradioboxgetrowcount}
+
+\constfunc{int}{GetRowCount}{\void}
+
+Returns the number of rows in the radiobox.
+
+
\membersection{wxRadioBox::GetSelection}\label{wxradioboxgetselection}
\constfunc{int}{GetSelection}{\void}
// change the individual radio button state
virtual bool Enable(int n, bool enable = true);
virtual bool Show(int n, bool show = true);
- // layout parameters
- virtual int GetColumnCount() const;
- virtual int GetRowCount() const;
protected:
virtual wxSize DoGetBestSize() const;
};
virtual bool Enable(int item, bool enable = true);
virtual bool Show(int item, bool show = true);
- virtual int GetColumnCount() const ;
- virtual int GetRowCount() const ;
-
-
virtual bool Enable(bool enable = true);
virtual wxString GetLabel() const;
virtual void SetLabel(const wxString& label) ;
protected:
wxRadioButton *m_radioButtonCycle;
- int m_majorDim ;
int m_noItems;
int m_noRowsOrCols;
virtual bool Enable(int item, bool enable = true);
virtual bool Show(int item, bool show = true);
- virtual int GetColumnCount() const ;
- virtual int GetRowCount() const ;
-
virtual bool Enable(bool enable = true);
virtual wxString GetLabel() const;
virtual void SetLabel(const wxString& label) ;
protected:
wxRadioButton *m_radioButtonCycle;
- int m_majorDim ;
int m_noItems;
int m_noRowsOrCols;
virtual int GetCount() const { return m_noItems; } ;
void Command(wxCommandEvent& event);
- int GetColumnCount() const;
- int GetRowCount() const;
-
int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
int width, int height,
int sizeFlags = wxSIZE_AUTO);
- int m_majorDim;
int m_noItems;
int m_noRowsOrCols;
int m_selectedButton;
virtual bool Show(int n, bool show = true);
virtual bool IsItemEnabled(int n) const;
virtual bool IsItemShown(int n) const;
- virtual int GetColumnCount() const { return GetNumHor(); }
- virtual int GetRowCount() const { return GetNumVer(); }
// override some base class methods
virtual bool Show(bool show = true);
void SendNotificationEvent();
- // get the number of buttons per column/row
- int GetNumVer() const;
- int GetNumHor() const;
-
protected:
// common part of all ctors
void Init();
int *m_radioWidth;
int *m_radioHeight;
- // the number of elements in major dimension (i.e. number of columns if
- // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS)
- int m_majorDim;
-
// currently selected button or wxNOT_FOUND if none
int m_selectedButton;
- virtual int GetColumnCount(void) const;
virtual int GetCount(void) const;
inline int GetNumberOfRowsOrCols(void) const { return m_nNoRowsOrCols; }
- int GetNumHor(void) const;
- int GetNumVer(void) const;
void GetPosition( int* pnX
,int* pnY
) const;
inline WXHWND* GetRadioButtons(void) const { return m_ahRadioButtons; }
- virtual int GetRowCount(void) const;
int GetSelection(void) const;
void GetSize( int* pnX
,int* pnY
WXHWND* m_ahRadioButtons;
- int m_nMajorDim ;
int* m_pnRadioWidth; // for bitmaps
int* m_pnRadioHeight;
int m_nNoItems;
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel();
- virtual int GetColumnCount() const;
- virtual int GetRowCount() const;
-
virtual void DoGetPosition( int *x, int *y ) const;
virtual void DoGetSize( int *width, int *height ) const;
virtual void DoMoveWindow(int x, int y, int width, int height);
void SendNotificationEvent();
- // get the number of buttons per column/row
- int GetNumVer() const;
- int GetNumHor() const;
-
protected:
// we can't compute our best size before the items are added to the control
virtual void SetInitialBestSize(const wxSize& WXUNUSED(size)) { }
// get the total size occupied by the radio box buttons
wxSize GetTotalButtonSize(const wxSize& sizeBtn) const;
- int m_majorDim;
int * m_radioWidth; // for bitmaps
int * m_radioHeight;
virtual bool IsItemEnabled(int WXUNUSED(n)) const { return true; }
virtual bool IsItemShown(int WXUNUSED(n)) const { return true; }
- // layout parameters
- virtual int GetColumnCount() const = 0;
- virtual int GetRowCount() const = 0;
+ // return number of columns/rows in this radiobox
+ int GetColumnCount() const { return m_numCols; }
+ int GetRowCount() const { return m_numRows; }
// return the item above/below/to the left/right of the given one
int GetNextItem(int item, wxDirection dir, long style) const;
wxDEPRECATED( int GetNumberOfRowsOrCols() const );
wxDEPRECATED( void SetNumberOfRowsOrCols(int n) );
#endif // WXWIN_COMPATIBILITY_2_4
+
+protected:
+ wxRadioBoxBase()
+ {
+ m_majorDim = 0;
+ }
+
+ // return the number of items in major direction (which depends on whether
+ // we have wxRA_SPECIFY_COLS or wxRA_SPECIFY_ROWS style)
+ int GetMajorDim() const { return m_majorDim; }
+
+ // sets m_majorDim and also updates m_numCols/Rows
+ //
+ // the style parameter should be the style of the radiobox itself
+ void SetMajorDim(int majorDim, long style);
+
+
+private:
+ // the number of elements in major dimension (i.e. number of columns if
+ // wxRA_SPECIFY_COLS or the number of rows if wxRA_SPECIFY_ROWS) and also
+ // the number of rows/columns calculated from it
+ int m_majorDim,
+ m_numCols,
+ m_numRows;
};
#if defined(__WXUNIVERSAL__)
virtual int GetSelection() const;
virtual int GetCount() const { return (int) m_buttons.GetCount(); }
- virtual int GetColumnCount() const { return m_numCols; }
- virtual int GetRowCount() const { return m_numRows; }
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label);
// common part of all ctors
void Init();
- // sets m_majorDim and calculate m_numCols and m_numRows
- void SetMajorDim(int majorDim);
-
// calculate the max size of all buttons
wxSize GetMaxButtonSize() const;
// the currently selected radio button or -1
int m_selection;
- // the parameters defining the button layout: majorDim meaning depends on
- // the style and is the (max) number of columns if it includes
- // wxRA_SPECIFY_COLS and is the (max) number of rows if it includes
- // wxRA_SPECIFY_ROWS - the number of rows and columns is calculated from
- // it
- int m_majorDim,
- m_numCols,
- m_numRows;
-
// all radio buttons
wxArrayRadioButtons m_buttons;
return false;
}
- // layout parameters
-int wxRadioBox::GetColumnCount() const
-{
- return 0;
-}
-
-int wxRadioBox::GetRowCount() const
-{
- return 0;
-}
-
wxSize wxRadioBox::DoGetBestSize() const
{
return wxSize(50,50);
// implementation
// ============================================================================
+void wxRadioBoxBase::SetMajorDim(int majorDim, long style)
+{
+ wxCHECK_RET( majorDim != 0, _T("major radiobox dimension can't be 0") );
+
+ m_majorDim = majorDim;
+
+ int minorDim = (GetCount() + m_majorDim - 1) / m_majorDim;
+
+ if ( style & wxRA_SPECIFY_COLS )
+ {
+ m_numCols = majorDim;
+ m_numRows = minorDim;
+ }
+ else // wxRA_SPECIFY_ROWS
+ {
+ m_numCols = minorDim;
+ m_numRows = majorDim;
+ }
+}
+
int wxRadioBoxBase::GetNextItem(int item, wxDirection dir, long style) const
{
int count = GetCount(),
{
m_noItems = 0;
m_noRowsOrCols = 0;
- m_majorDim = 0 ;
m_radioButtonCycle = NULL;
}
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
- if (majorDim==0)
- m_majorDim = n ;
- else
- m_majorDim = majorDim ;
-
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
m_label = label ;
current=m_radioButtonCycle;
for ( i = 0 ; i < m_noItems; i++)
{
- if (i&&((i%m_majorDim)==0)) // not to do for the zero button!
+ if (i&&((i%GetMajorDim())==0)) // not to do for the zero button!
{
if (m_windowStyle & wxRA_SPECIFY_ROWS)
{
return wxSize(totWidth, totHeight);
}
-//-------------------------------------------------------------------------------------
-// ¥ GetNumVer
-//-------------------------------------------------------------------------------------
-// return the number of buttons in the vertical direction
-
-int wxRadioBox::GetRowCount() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return m_majorDim;
- }
- else
- {
- return (m_noItems + m_majorDim - 1)/m_majorDim;
- }
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ GetNumHor
-//-------------------------------------------------------------------------------------
-// return the number of buttons in the horizontal direction
-
-int wxRadioBox::GetColumnCount() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return (m_noItems + m_majorDim - 1)/m_majorDim;
- }
- else
- {
- return m_majorDim;
- }
-}
-
-#endif
{
m_noItems = 0;
m_noRowsOrCols = 0;
- m_majorDim = 0 ;
m_radioButtonCycle = NULL;
}
m_noRowsOrCols = majorDim;
m_radioButtonCycle = NULL;
- if (majorDim==0)
- m_majorDim = n ;
- else
- m_majorDim = majorDim ;
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
Rect bounds ;
Str255 title ;
current=m_radioButtonCycle;
for ( i = 0 ; i < m_noItems; i++)
{
- if (i&&((i%m_majorDim)==0)) // not to do for the zero button!
+ if (i&&((i%GetMajorDim())==0)) // not to do for the zero button!
{
if (m_windowStyle & wxRA_VERTICAL)
{
return wxSize(totWidth, totHeight);
}
-//-------------------------------------------------------------------------------------
-// ¥ GetNumVer
-//-------------------------------------------------------------------------------------
-// return the number of buttons in the vertical direction
-
-int wxRadioBox::GetRowCount() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return m_majorDim;
- }
- else
- {
- return (m_noItems + m_majorDim - 1)/m_majorDim;
- }
-}
-
-//-------------------------------------------------------------------------------------
-// ¥ GetNumHor
-//-------------------------------------------------------------------------------------
-// return the number of buttons in the horizontal direction
-
-int wxRadioBox::GetColumnCount() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return (m_noItems + m_majorDim - 1)/m_majorDim;
- }
- else
- {
- return m_majorDim;
- }
-}
m_selectedButton = -1;
m_noItems = 0;
m_noRowsOrCols = 0;
- m_majorDim = 0 ;
}
bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
m_noItems = n;
m_noRowsOrCols = majorDim;
- if (majorDim==0)
- m_majorDim = n ;
- else
- m_majorDim = majorDim ;
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
Widget parentWidget = (Widget) parent->GetClientWidget();
Display* dpy = XtDisplay(parentWidget);
Arg args[3];
- m_majorDim = (n + m_majorDim - 1) / m_majorDim;
-
XtSetArg (args[0], XmNorientation, ((style & wxHORIZONTAL) == wxHORIZONTAL ?
XmHORIZONTAL : XmVERTICAL));
- XtSetArg (args[1], XmNnumColumns, m_majorDim);
+ XtSetArg (args[1], XmNnumColumns, GetMajorDim());
XtSetArg (args[2], XmNadjustLast, False);
Widget radioBoxWidget =
}
}
-static int CalcOtherDim( int items, int dim )
-{
- return items / dim + ( items % dim ? 1 : 0 );
-}
-
-int wxRadioBox::GetRowCount() const
-{
- return m_windowStyle & wxRA_SPECIFY_ROWS ? m_noRowsOrCols
- : CalcOtherDim( GetCount(), m_noRowsOrCols );
-}
-
-int wxRadioBox::GetColumnCount() const
-{
- return m_windowStyle & wxRA_SPECIFY_COLS ? m_noRowsOrCols
- : CalcOtherDim( GetCount(), m_noRowsOrCols );
-}
-
void wxRadioBoxCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs)
{
{
m_selectedButton = wxNOT_FOUND;
m_radioButtons = NULL;
- m_majorDim = 0;
m_radioWidth = NULL;
m_radioHeight = NULL;
}
const wxString& name)
{
// initialize members
- m_majorDim = majorDim == 0 ? n : majorDim;
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
// common initialization
if ( !wxStaticBox::Create(parent, id, title, pos, size, style, name) )
return m_radioButtons->GetCount();
}
-// returns the number of rows
-int wxRadioBox::GetNumVer() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return m_majorDim;
- }
- else
- {
- return (GetCount() + m_majorDim - 1)/m_majorDim;
- }
-}
-
-// returns the number of columns
-int wxRadioBox::GetNumHor() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return (GetCount() + m_majorDim - 1)/m_majorDim;
- }
- else
- {
- return m_majorDim;
- }
-}
-
void wxRadioBox::SetString(int item, const wxString& label)
{
wxCHECK_RET( IsValid(item), wxT("invalid radiobox index") );
int extraHeight = cy1;
- int height = GetNumVer() * sizeBtn.y + cy1/2 + extraHeight;
- int width = GetNumHor() * (sizeBtn.x + cx1) + cx1;
+ int height = GetRowCount() * sizeBtn.y + cy1/2 + extraHeight;
+ int width = GetColumnCount() * (sizeBtn.x + cx1) + cx1;
// Add extra space under the label, if it exists.
if (!wxControl::GetLabel().empty())
// 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 m_majorDim is the number of columns while
+ // 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
- // m_majorDim is the number of rows.
+ // GetMajorDim() is the number of rows.
x_offset += cx1;
y_offset += cy1;
// 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
int n = i + 1;
- isLastInTheRow = ((n % m_majorDim) == 0) || (n == count);
+ 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/m_majorDim)*m_majorDim;
+ isLastInTheRow = i >= (count/GetMajorDim())*GetMajorDim();
}
// is this the start of new row/column?
- if ( i && (i % m_majorDim == 0) )
+ if ( i && (i % GetMajorDim() == 0) )
{
if ( m_windowStyle & wxRA_SPECIFY_ROWS )
{
m_nNoItems = 0;
m_nNoRowsOrCols = 0;
m_ahRadioButtons = NULL;
- m_nMajorDim = 0;
m_pnRadioWidth = NULL;
m_pnRadioHeight = NULL;
} // end of wxRadioBox::wxRadioBox
//
int n = i + 1;
- bIsLastInTheRow = ((n % m_nMajorDim) == 0) || (n == m_nNoItems);
+ bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems);
}
else // winRA_SPECIFY_ROWS
{
//
// Item is the last in the row if it is in the last columns
//
- bIsLastInTheRow = i >= (m_nNoItems/m_nMajorDim) * m_nMajorDim;
+ bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim();
}
//
// Is this the start of new row/column?
//
- if (i && (i % m_nMajorDim == 0))
+ if (i && (i % GetMajorDim() == 0))
{
if (m_windowStyle & wxRA_SPECIFY_ROWS)
{
m_nSelectedButton = -1;
m_nNoItems = 0;
- m_nMajorDim = nMajorDim == 0 ? nNum : nMajorDim;
+ SetMajorDim(majorDim == 0 ? n : majorDim, lStyle);
m_nNoRowsOrCols = nMajorDim;
//
//
int n = i + 1;
- bIsLastInTheRow = ((n % m_nMajorDim) == 0) || (n == m_nNoItems);
+ bIsLastInTheRow = ((n % GetMajorDim()) == 0) || (n == m_nNoItems);
}
else // winRA_SPECIFY_ROWS
{
//
// Item is the last in the row if it is in the last columns
//
- bIsLastInTheRow = i >= (m_nNoItems/m_nMajorDim) * m_nMajorDim;
+ bIsLastInTheRow = i >= (m_nNoItems/GetMajorDim()) * GetMajorDim();
}
//
// Is this the start of new row/column?
//
- if (i && (i % m_nMajorDim == 0))
+ if (i && (i % GetMajorDim() == 0))
{
if (m_windowStyle & wxRA_SPECIFY_ROWS)
{
return true;
} // end of wxRadioBox::Enable
-int wxRadioBox::GetColumnCount() const
-{
- return GetNumHor();
-} // end of wxRadioBox::GetColumnCount
-
int wxRadioBox::GetCount() const
{
return m_nNoItems;
return maxsize;
} // end of wxRadioBox::GetMaxButtonSize
-int wxRadioBox::GetNumHor() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return (m_nNoItems + m_nMajorDim - 1)/m_nMajorDim;
- }
- else
- {
- return m_nMajorDim;
- }
-} // end of wxRadioBox::GetNumHor
-
-int wxRadioBox::GetNumVer() const
-{
- if ( m_windowStyle & wxRA_SPECIFY_ROWS )
- {
- return m_nMajorDim;
- }
- else
- {
- return (m_nNoItems + m_nMajorDim - 1)/m_nMajorDim;
- }
-} // end of wxRadioBox::GetNumVer
-
void wxRadioBox::GetPosition( int* pnX,
int* WXUNUSED(pnY) ) const
{
*pnX = vPoint.y;
} // end of wxRadioBox::GetPosition
-int wxRadioBox::GetRowCount() const
-{
- return GetNumVer();
-} // end of wxRadioBox::GetRowCount
-
// Get single selection, for single choice list items
int wxRadioBox::GetSelection() const
{
nCx1 = GetCharWidth();
nCy1 = GetCharHeight();
- nHeight = GetNumVer() * rSizeBtn.y + (2 * nCy1);
- nWidth = GetNumHor() * (rSizeBtn.x + nCx1) + nCx1;
+ nHeight = GetRowCount() * rSizeBtn.y + (2 * nCy1);
+ nWidth = GetColumnCount() * (rSizeBtn.x + nCx1) + nCx1;
//
// And also wide enough for its label
return m_radios.GetCount();
}
-int wxRadioBox::GetColumnCount() const
-{
- return 0;
-}
-
-int wxRadioBox::GetRowCount() const
-{
- return 0;
-}
-
-// returns the number of rows
-int wxRadioBox::GetNumVer() const
-{
- return 0;
-}
-
-// returns the number of columns
-int wxRadioBox::GetNumHor() const
-{
- return 0;
-}
-
bool wxRadioBox::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxString& name)
{
// initialize members
- m_majorDim = majorDim == 0 ? n : wxMin(majorDim, n);
- if(m_majorDim==0 || n==0) return false;
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
+
+ if ( GetMajorDim() == 0 || n == 0 )
+ return false;
// subtype of the native palmOS radio: checkbox or push button?
const bool use_checkbox = style & wxRA_USE_CHECKBOX;
// get default size and position for the initial placement
m_size = size;
m_pos = pos;
- int minor = n / m_majorDim;
- if(n % m_majorDim > 0) minor++;
+ int minor = n / GetMajorDim();
+ if(n % GetMajorDim() > 0)
+ minor++;
if(m_size.x==wxDefaultCoord)
- m_size.x=36*(use_cols?m_majorDim:minor);
+ m_size.x=36*(use_cols?GetMajorDim():minor);
if(m_size.y==wxDefaultCoord)
- m_size.y=12*(use_cols?minor:m_majorDim);
+ m_size.y=12*(use_cols?minor:GetMajorDim());
if(m_pos.x==wxDefaultCoord)
m_pos.x=0;
if(m_pos.y==wxDefaultCoord)
int i = 0;
for ( int j = 0; j < minor; j++ )
{
- for ( int k = 0; k < m_majorDim; k++ )
+ for ( int k = 0; k < GetMajorDim(); k++ )
{
if(i<n)
{
wxPoint start, end;
- start.x = (use_cols ? (k*m_size.x)/m_majorDim : (j*m_size.x)/minor);
- start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/m_majorDim);
- end.x = (use_cols ? ((k+1)*m_size.x)/m_majorDim : ((j+1)*m_size.x)/minor);
- end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/m_majorDim);
+ start.x = (use_cols ? (k*m_size.x)/GetMajorDim() : (j*m_size.x)/minor);
+ start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/GetMajorDim());
+ end.x = (use_cols ? ((k+1)*m_size.x)/GetMajorDim() : ((j+1)*m_size.x)/minor);
+ end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/GetMajorDim());
wxRadioButton* rb = new wxRadioButton();
rb->SetGroup( id );
rb->Create(
const bool use_cols = HasFlag(wxRA_SPECIFY_COLS);
const int n = GetCount();
- int minor = n / m_majorDim;
- if(n % m_majorDim > 0) minor++;
+ int minor = n / GetMajorDim();
+ if(n % GetMajorDim() > 0)
+ minor++;
int i = 0;
for ( int j = 0; j < minor; j++ )
{
- for ( int k = 0; k < m_majorDim; k++ )
+ for ( int k = 0; k < GetMajorDim(); k++ )
{
if(i<n)
{
wxPoint start, end;
- start.x = (use_cols ? (k*m_size.x)/m_majorDim : (j*m_size.x)/minor);
- start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/m_majorDim);
- end.x = (use_cols ? ((k+1)*m_size.x)/m_majorDim : ((j+1)*m_size.x)/minor);
- end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/m_majorDim);
+ start.x = (use_cols ? (k*m_size.x)/GetMajorDim() : (j*m_size.x)/minor);
+ start.y = (use_cols ? (j*m_size.y)/minor : (k*m_size.y)/GetMajorDim());
+ end.x = (use_cols ? ((k+1)*m_size.x)/GetMajorDim() : ((j+1)*m_size.x)/minor);
+ end.y = (use_cols ? ((j+1)*m_size.y)/minor : ((k+1)*m_size.y)/GetMajorDim());
wxRadioButton* rb = GetRadioButton(i);
if(rb)
{
void wxRadioBox::Init()
{
m_selection = -1;
- m_majorDim = 0;
}
wxRadioBox::wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
Append(n, choices);
// majorDim default value is 0 which means make one row/column
- SetMajorDim(majorDim == 0 ? n : majorDim);
+ SetMajorDim(majorDim == 0 ? n : majorDim, style);
if ( size == wxDefaultSize )
{
// wxRadioBox init
// ----------------------------------------------------------------------------
-void wxRadioBox::SetMajorDim(int majorDim)
-{
- wxCHECK_RET( majorDim != 0, _T("major radiobox dimension can't be 0") );
-
- m_majorDim = majorDim;
-
- int minorDim = (GetCount() + m_majorDim - 1) / m_majorDim;
-
- if ( GetWindowStyle() & wxRA_SPECIFY_COLS )
- {
- m_numCols = majorDim;
- m_numRows = minorDim;
- }
- else // wxRA_SPECIFY_ROWS
- {
- m_numCols = minorDim;
- m_numRows = majorDim;
- }
-}
-
void wxRadioBox::Append(int count, const wxString *choices)
{
if ( !count )
{
wxSize sizeBtn = GetMaxButtonSize();
- sizeBtn.x *= m_numCols;
- sizeBtn.y *= m_numRows;
+ sizeBtn.x *= GetColumnCount();
+ sizeBtn.y *= GetRowCount();
// add a border around all buttons
sizeBtn.x += 2*BOX_BORDER_X;
if ( GetWindowStyle() & wxRA_TOPTOBOTTOM )
{
// from top to bottom
- if ( (n + 1) % m_numRows )
+ if ( (n + 1) % GetRowCount() )
{
// continue in this column
y += sizeBtn.y;
else // wxRA_LEFTTORIGHT: mirror the code above
{
// from left to right
- if ( (n + 1) % m_numCols )
+ if ( (n + 1) % GetColumnCount() )
{
// continue in this row
x += sizeBtn.x;