]>
git.saurik.com Git - wxWidgets.git/blob - src/common/radiocmn.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/radiocmn.cpp
3 // Purpose: wxRadioBox methods common to all ports
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // License: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
30 #include "wx/radiobox.h"
33 // ============================================================================
35 // ============================================================================
37 void wxRadioBoxBase::SetMajorDim(unsigned int majorDim
, long style
)
39 wxCHECK_RET( majorDim
!= 0, _T("major radiobox dimension can't be 0") );
41 m_majorDim
= majorDim
;
43 int minorDim
= (GetCount() + m_majorDim
- 1) / m_majorDim
;
45 if ( style
& wxRA_SPECIFY_COLS
)
50 else // wxRA_SPECIFY_ROWS
57 int wxRadioBoxBase::GetNextItem(int item
, wxDirection dir
, long style
) const
59 int count
= GetCount(),
60 numCols
= GetColumnCount(),
61 numRows
= GetRowCount();
63 bool horz
= (style
& wxRA_SPECIFY_COLS
) != 0;
72 else // vertical layout
85 else // vertical layout
96 else // vertical layout
98 if ( ++item
== count
)
106 if ( ++item
== count
)
109 else // vertical layout
116 wxFAIL_MSG( _T("unexpected wxDirection value") );
120 // ensure that the item is in range [0..count)
123 // first map the item to the one in the same column but in the last row
126 // now there are 2 cases: either it is the first item of the last row
127 // in which case we need to wrap again and get to the last item or we
128 // can just go to the previous item
129 if ( item
% (horz
? numCols
: numRows
) )
134 else if ( item
>= count
)
136 // same logic as above
139 // ... except that we need to check if this is not the last item, not
141 if ( (item
+ 1) % (horz
? numCols
: numRows
) )
147 wxASSERT_MSG( item
< count
&& item
>= 0,
148 _T("logic error in wxRadioBox::GetNextItem()") );
153 #if WXWIN_COMPATIBILITY_2_4
155 // these functions are deprecated and don't do anything
156 int wxRadioBoxBase::GetNumberOfRowsOrCols() const
161 void wxRadioBoxBase::SetNumberOfRowsOrCols(int WXUNUSED(n
))
165 #endif // WXWIN_COMPATIBILITY_2_4
167 #endif // wxUSE_RADIOBOX