git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32325
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
12 files changed:
virtual void SetString(int n, const wxString& label);
// change the individual radio button state
virtual bool Enable(int n, bool enable = true);
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;
// layout parameters
virtual int GetColumnCount() const;
virtual int GetRowCount() const;
// reads better for multi-selection ones
void Select(int n) { SetSelection(n); }
// 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
};
class WXDLLEXPORT wxItemContainer : public wxItemContainerImmutable
wxString GetString( int n ) const;
void SetString( int n, const wxString& label );
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;
virtual bool Enable( int item, bool enable = true );
virtual wxString GetStringSelection() const;
// common part of all ctors
void Init();
// 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)
};
private:
DECLARE_DYNAMIC_CLASS(wxRadioBox)
};
wxString GetString( int n ) const;
void SetString( int n, const wxString& label );
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;
virtual bool Enable( int item, bool enable = true );
virtual wxString GetStringSelection() const;
// common part of all ctors
void Init();
// 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)
};
private:
DECLARE_DYNAMIC_CLASS(wxRadioBox)
};
wxString GetString(int item) const;
virtual bool Enable(bool enable = true);
virtual bool Enable(int item, bool enable = true);
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 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 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(); }
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;
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;
// layout parameters
virtual int GetColumnCount() const = 0;
-void wxRadioBox::Show(int n, bool show)
+bool wxRadioBox::Show(int n, bool show)
+ // TODO
+ return false;
int wxRadioBox::FindString( const wxString &find ) const
{
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") );
node = node->GetNext();
}
node = node->GetNext();
}
}
void wxRadioBox::SetFocus()
}
void wxRadioBox::SetFocus()
int wxRadioBox::GetSelection(void) const
{
int wxRadioBox::GetSelection(void) const
{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
wxFAIL_MSG( wxT("wxRadioBox none selected") );
wxFAIL_MSG( wxT("wxRadioBox none selected") );
}
wxString wxRadioBox::GetString( int n ) const
}
wxString wxRadioBox::GetString( int n ) const
-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 );
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() );
GtkWidget *button = GTK_WIDGET( node->GetData() );
gtk_widget_show( button );
else
gtk_widget_hide( button );
gtk_widget_show( button );
else
gtk_widget_hide( button );
}
wxString wxRadioBox::GetStringSelection() const
}
wxString wxRadioBox::GetStringSelection() const
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
int res = FindString( s );
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;
SetSelection( res );
return true;
int wxRadioBox::FindString( const wxString &find ) const
{
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") );
node = node->GetNext();
}
node = node->GetNext();
}
}
void wxRadioBox::SetFocus()
}
void wxRadioBox::SetFocus()
int wxRadioBox::GetSelection(void) const
{
int wxRadioBox::GetSelection(void) const
{
- wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid radiobox") );
+ wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid radiobox") );
wxFAIL_MSG( wxT("wxRadioBox none selected") );
wxFAIL_MSG( wxT("wxRadioBox none selected") );
}
wxString wxRadioBox::GetString( int n ) const
}
wxString wxRadioBox::GetString( int n ) const
-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 );
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() );
GtkWidget *button = GTK_WIDGET( node->GetData() );
gtk_widget_show( button );
else
gtk_widget_hide( button );
gtk_widget_show( button );
else
gtk_widget_hide( button );
}
wxString wxRadioBox::GetStringSelection() const
}
wxString wxRadioBox::GetStringSelection() const
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
int res = FindString( s );
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;
SetSelection( res );
return true;
void wxRadioBox::SetString(int item, const wxString& label)
{
void wxRadioBox::SetString(int item, const wxString& label)
{
- if (item < 0 || item >= m_noItems)
return;
Widget widget = (Widget) m_radioButtons[item];
return;
Widget widget = (Widget) m_radioButtons[item];
for (i = 0; i < m_noItems; i++)
if (s == m_radioButtonLabels[i])
return i;
for (i = 0; i < m_noItems; i++)
if (s == m_radioButtonLabels[i])
return i;
}
void wxRadioBox::SetSelection(int n)
{
}
void wxRadioBox::SetSelection(int n)
{
- if ((n < 0) || (n >= m_noItems))
return;
m_selectedButton = n;
return;
m_selectedButton = n;
// Find string for position
wxString wxRadioBox::GetString(int n) const
{
// Find string for position
wxString wxRadioBox::GetString(int n) const
{
- if ((n < 0) || (n >= m_noItems))
return wxEmptyString;
return m_radioButtonLabels[n];
}
return wxEmptyString;
return m_radioButtonLabels[n];
}
// Enable a specific button
bool wxRadioBox::Enable(int n, bool enable)
{
// Enable a specific button
bool wxRadioBox::Enable(int n, bool enable)
{
- if ((n < 0) || (n >= m_noItems))
return false;
XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable);
return false;
XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable);
}
// Show a specific button
}
// 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,
{
// 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)
//
// 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,
XtVaSetValues ((Widget) m_radioButtons[n],
XmNindicatorOn, (unsigned char) show,
// after this call!!
if (!show)
wxRadioBox::SetString (n, " ");
// after this call!!
if (!show)
wxRadioBox::SetString (n, " ");
}
// For single selection items only
}
// For single selection items only
void wxRadioBox::SetString(int item, const wxString& label)
{
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;
m_radioWidth[item] =
m_radioHeight[item] = wxDefaultCoord;
void wxRadioBox::SetSelection(int N)
{
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 )
// unselect the old button
if ( m_selectedButton != wxNOT_FOUND )
// Find string for position
wxString wxRadioBox::GetString(int item) const
{
// 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]);
wxT("invalid radiobox index") );
return wxGetWindowText((*m_radioButtons)[item]);
// Enable a specific button
bool wxRadioBox::Enable(int item, bool enable)
{
// 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()") );
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
}
// 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()") );
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)
}
WX_FORWARD_STD_METHODS_TO_SUBWINDOWS(wxRadioBox, wxStaticBox, m_radioButtons)