]>
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 int wxRadioBoxBase::FindString(const wxString
& s
) const
39 int count
= GetCount();
40 for ( int n
= 0; n
< count
; n
++ )
42 if ( GetString(n
) == s
)
49 int wxRadioBoxBase::GetNextItem(int item
, wxDirection dir
, long style
) const
51 int count
= GetCount(),
52 numCols
= GetColumnCount(),
53 numRows
= GetRowCount();
55 bool horz
= (style
& wxRA_SPECIFY_COLS
) != 0;
64 else // vertical layout
77 else // vertical layout
88 else // vertical layout
90 if ( ++item
== count
)
98 if ( ++item
== count
)
101 else // vertical layout
108 wxFAIL_MSG( _T("unexpected wxDirection value") );
112 // ensure that the item is in range [0..count)
115 // first map the item to the one in the same column but in the last row
118 // now there are 2 cases: either it is the first item of the last row
119 // in which case we need to wrap again and get to the last item or we
120 // can just go to the previous item
121 if ( item
% (horz
? numCols
: numRows
) )
126 else if ( item
>= count
)
128 // same logic as above
131 // ... except that we need to check if this is not the last item, not
133 if ( (item
+ 1) % (horz
? numCols
: numRows
) )
139 wxASSERT_MSG( item
< count
&& item
>= 0,
140 _T("logic error in wxRadioBox::GetNextItem()") );
145 #if WXWIN_COMPATIBILITY_2_4
147 // these functions are deprecated and don't do anything
148 int wxRadioBoxBase::GetNumberOfRowsOrCols() const
153 void wxRadioBoxBase::SetNumberOfRowsOrCols(int WXUNUSED(n
))
157 #endif // WXWIN_COMPATIBILITY_2_4
159 #if WXWIN_COMPATIBILITY_2_2
161 int wxRadioBoxBase::Number() const
166 wxString
wxRadioBoxBase::GetLabel(int n
) const
171 void wxRadioBoxBase::SetLabel(int n
, const wxString
& label
)
176 #endif // WXWIN_COMPATIBILITY_2_2
178 #endif // wxUSE_RADIOBOX