virtual void SetString(int n, const wxString& label);
// change the individual radio button state
virtual bool Enable(int n, bool enable = true);
- virtual void Show(int n, bool show = true);
+ virtual bool Show(int n, bool show = true);
// layout parameters
virtual int GetColumnCount() const;
virtual int GetRowCount() const;
// reads better for multi-selection ones
void Select(int n) { SetSelection(n); }
+
+protected:
+
+ // check that the index is valid
+ inline bool IsValid(int n) const { return n >= 0 && n < GetCount(); }
};
class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable
wxString GetString( int n ) const;
void SetString( int n, const wxString& label );
- void Show( int item, bool show );
+ virtual bool Show( int item, bool show = true );
virtual bool Enable( int item, bool enable = true );
virtual wxString GetStringSelection() const;
// common part of all ctors
void Init();
+ // check that the index is valid
+ // FIXME: remove once GTK will derive from wxRadioBoxBase
+ inline bool IsValid(int n) const { return n >= 0 && n < GetCount(); }
+
private:
DECLARE_DYNAMIC_CLASS(wxRadioBox)
};
wxString GetString( int n ) const;
void SetString( int n, const wxString& label );
- void Show( int item, bool show );
+ virtual bool Show( int item, bool show = true );
virtual bool Enable( int item, bool enable = true );
virtual wxString GetStringSelection() const;
// common part of all ctors
void Init();
+ // check that the index is valid
+ // FIXME: remove once GTK will derive from wxRadioBoxBase
+ inline bool IsValid(int n) const { return n >= 0 && n < GetCount(); }
+
private:
DECLARE_DYNAMIC_CLASS(wxRadioBox)
};
wxString GetString(int item) const;
virtual bool Enable(bool enable = true);
virtual bool Enable(int item, bool enable = true);
- void Show(int item, bool show) ;
- virtual bool Show(bool show = true) ;
+ virtual bool Show(int item, bool show = true);
+ virtual bool Show(bool show = true);
virtual wxString GetStringSelection() const;
virtual bool SetStringSelection(const wxString& s);
virtual wxString GetString(int n) const;
virtual void SetString(int n, const wxString& label);
virtual bool Enable(int n, bool enable = true);
- virtual void Show(int n, bool show = true);
+ virtual bool Show(int n, bool show = true);
virtual int GetColumnCount() const { return GetNumHor(); }
virtual int GetRowCount() const { return GetNumVer(); }
public:
// change the individual radio button state
virtual bool Enable(int n, bool enable = true) = 0;
- virtual void Show(int n, bool show = true) = 0;
+ virtual bool Show(int n, bool show = true) = 0;
// layout parameters
virtual int GetColumnCount() const = 0;
return false;
}
-void wxRadioBox::Show(int n, bool show)
+bool wxRadioBox::Show(int n, bool show)
{
+ // TODO
+ return false;
}
// layout parameters
int wxRadioBox::FindString( const wxString &find ) const
{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
int count = 0;
node = node->GetNext();
}
- return -1;
+ return wxNOT_FOUND;
}
void wxRadioBox::SetFocus()
int wxRadioBox::GetSelection(void) const
{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
int count = 0;
wxFAIL_MSG( wxT("wxRadioBox none selected") );
- return -1;
+ return wxNOT_FOUND;
}
wxString wxRadioBox::GetString( int n ) const
return true;
}
-void wxRadioBox::Show( int item, bool show )
+bool wxRadioBox::Show( int item, bool show )
{
- wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.Item( item );
- wxCHECK_RET( node, wxT("radiobox wrong index") );
+ wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
GtkWidget *button = GTK_WIDGET( node->GetData() );
gtk_widget_show( button );
else
gtk_widget_hide( button );
+
+ return true;
}
wxString wxRadioBox::GetStringSelection() const
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
int res = FindString( s );
- if (res == -1) return false;
+ if (res == wxNOT_FOUND) return false;
SetSelection( res );
return true;
int wxRadioBox::FindString( const wxString &find ) const
{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
int count = 0;
node = node->GetNext();
}
- return -1;
+ return wxNOT_FOUND;
}
void wxRadioBox::SetFocus()
int wxRadioBox::GetSelection(void) const
{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
int count = 0;
wxFAIL_MSG( wxT("wxRadioBox none selected") );
- return -1;
+ return wxNOT_FOUND;
}
wxString wxRadioBox::GetString( int n ) const
return true;
}
-void wxRadioBox::Show( int item, bool show )
+bool wxRadioBox::Show( int item, bool show )
{
- wxCHECK_RET( m_widget != NULL, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
wxList::compatibility_iterator node = m_boxes.Item( item );
- wxCHECK_RET( node, wxT("radiobox wrong index") );
+ wxCHECK_MSG( node, false, wxT("radiobox wrong index") );
GtkWidget *button = GTK_WIDGET( node->GetData() );
gtk_widget_show( button );
else
gtk_widget_hide( button );
+
+ return true;
}
wxString wxRadioBox::GetStringSelection() const
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
int res = FindString( s );
- if (res == -1) return false;
+ if (res == wxNOT_FOUND) return false;
SetSelection( res );
return true;
void wxRadioBox::SetString(int item, const wxString& label)
{
- if (item < 0 || item >= m_noItems)
+ if (!IsValid(item))
return;
Widget widget = (Widget) m_radioButtons[item];
for (i = 0; i < m_noItems; i++)
if (s == m_radioButtonLabels[i])
return i;
- return -1;
+ return wxNOT_FOUND;
}
void wxRadioBox::SetSelection(int n)
{
- if ((n < 0) || (n >= m_noItems))
+ if (!IsValid(n))
return;
m_selectedButton = n;
// Find string for position
wxString wxRadioBox::GetString(int n) const
{
- if ((n < 0) || (n >= m_noItems))
+ if (!IsValid(n))
return wxEmptyString;
return m_radioButtonLabels[n];
}
// Enable a specific button
bool wxRadioBox::Enable(int n, bool enable)
{
- if ((n < 0) || (n >= m_noItems))
+ if (!IsValid(n))
return false;
XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable);
}
// Show a specific button
-void wxRadioBox::Show(int n, bool show)
+bool wxRadioBox::Show(int n, bool show)
{
// This method isn't complete, and we try do do our best...
// It's main purpose isn't for allowing Show/Unshow dynamically,
// In my case, this is a 'direction' box, and the Show(5,False) is
// coupled with an Enable(5,False)
//
- if ((n < 0) || (n >= m_noItems))
- return;
+ if (!IsValid(n))
+ return false;
XtVaSetValues ((Widget) m_radioButtons[n],
XmNindicatorOn, (unsigned char) show,
// after this call!!
if (!show)
wxRadioBox::SetString (n, " ");
+
+ return true;
}
// For single selection items only
void wxRadioBox::SetString(int item, const wxString& label)
{
- wxCHECK_RET( item >= 0 && item < GetCount(), wxT("invalid radiobox index") );
+ wxCHECK_RET( IsValid(item), wxT("invalid radiobox index") );
m_radioWidth[item] =
m_radioHeight[item] = wxDefaultCoord;
void wxRadioBox::SetSelection(int N)
{
- wxCHECK_RET( (N >= 0) && (N < GetCount()), wxT("invalid radiobox index") );
+ wxCHECK_RET( IsValid(N), wxT("invalid radiobox index") );
// unselect the old button
if ( m_selectedButton != wxNOT_FOUND )
// Find string for position
wxString wxRadioBox::GetString(int item) const
{
- wxCHECK_MSG( item >= 0 && item < GetCount(), wxEmptyString,
+ wxCHECK_MSG( IsValid(item), wxEmptyString,
wxT("invalid radiobox index") );
return wxGetWindowText((*m_radioButtons)[item]);
// Enable a specific button
bool wxRadioBox::Enable(int item, bool enable)
{
- wxCHECK_MSG( item >= 0 && item < GetCount(), false,
+ wxCHECK_MSG( IsValid(item), false,
wxT("invalid item in wxRadioBox::Enable()") );
- ::EnableWindow((*m_radioButtons)[item], enable);
- return true;
+ BOOL ret = ::EnableWindow((*m_radioButtons)[item], enable);
+
+ return (ret == 0) == enable;
}
// Show a specific button
-void wxRadioBox::Show(int item, bool show)
+bool wxRadioBox::Show(int item, bool show)
{
- wxCHECK_RET( item >= 0 && item < GetCount(),
+ wxCHECK_MSG( IsValid(item), false,
wxT("invalid item in wxRadioBox::Show()") );
- ::ShowWindow((*m_radioButtons)[item], show ? SW_SHOW : SW_HIDE);
+ BOOL ret = ::ShowWindow((*m_radioButtons)[item], show ? SW_SHOW : SW_HIDE);
+
+ return (ret != 0) == show;
}
WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox, wxStaticBox, m_radioButtons)