Linup API of wxRadioBox::Show on all ports. Move wxRadioBox::IsValid from wxUniversal to base class (+ GTK which do not use base class) and use it where applicable. Minor source cleaning.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32325 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -90,7 +90,7 @@ public:
|
|||||||
virtual void SetString(int n, const wxString& label);
|
virtual void SetString(int n, const wxString& label);
|
||||||
// change the individual radio button state
|
// change the individual radio button state
|
||||||
virtual bool Enable(int n, bool enable = true);
|
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
|
// layout parameters
|
||||||
virtual int GetColumnCount() const;
|
virtual int GetColumnCount() const;
|
||||||
virtual int GetRowCount() const;
|
virtual int GetRowCount() const;
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ public:
|
|||||||
// reads better for multi-selection ones
|
// reads better for multi-selection ones
|
||||||
void Select(int n) { SetSelection(n); }
|
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
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
wxString GetString( int n ) const;
|
wxString GetString( int n ) const;
|
||||||
void SetString( int n, const wxString& label );
|
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 bool Enable( int item, bool enable = true );
|
||||||
|
|
||||||
virtual wxString GetStringSelection() const;
|
virtual wxString GetStringSelection() const;
|
||||||
@@ -142,6 +142,10 @@ protected:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
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:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxRadioBox)
|
DECLARE_DYNAMIC_CLASS(wxRadioBox)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public:
|
|||||||
wxString GetString( int n ) const;
|
wxString GetString( int n ) const;
|
||||||
void SetString( int n, const wxString& label );
|
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 bool Enable( int item, bool enable = true );
|
||||||
|
|
||||||
virtual wxString GetStringSelection() const;
|
virtual wxString GetStringSelection() const;
|
||||||
@@ -142,6 +142,10 @@ protected:
|
|||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init();
|
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:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxRadioBox)
|
DECLARE_DYNAMIC_CLASS(wxRadioBox)
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -84,8 +84,8 @@ public:
|
|||||||
wxString GetString(int item) const;
|
wxString GetString(int item) const;
|
||||||
virtual bool Enable(bool enable = true);
|
virtual bool Enable(bool enable = true);
|
||||||
virtual bool Enable(int item, bool enable = true);
|
virtual bool Enable(int item, bool enable = true);
|
||||||
void Show(int item, bool show) ;
|
virtual bool Show(int item, bool show = true);
|
||||||
virtual bool Show(bool show = true) ;
|
virtual bool Show(bool show = true);
|
||||||
|
|
||||||
virtual wxString GetStringSelection() const;
|
virtual wxString GetStringSelection() const;
|
||||||
virtual bool SetStringSelection(const wxString& s);
|
virtual bool SetStringSelection(const wxString& s);
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ public:
|
|||||||
virtual wxString GetString(int n) const;
|
virtual wxString GetString(int n) const;
|
||||||
virtual void SetString(int n, const wxString& label);
|
virtual void SetString(int n, const wxString& label);
|
||||||
virtual bool Enable(int n, bool enable = true);
|
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 GetColumnCount() const { return GetNumHor(); }
|
||||||
virtual int GetRowCount() const { return GetNumVer(); }
|
virtual int GetRowCount() const { return GetNumVer(); }
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class WXDLLEXPORT wxRadioBoxBase : public wxItemContainerImmutable
|
|||||||
public:
|
public:
|
||||||
// change the individual radio button state
|
// change the individual radio button state
|
||||||
virtual bool Enable(int n, bool enable = true) = 0;
|
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
|
// layout parameters
|
||||||
virtual int GetColumnCount() const = 0;
|
virtual int GetColumnCount() const = 0;
|
||||||
|
|||||||
@@ -97,8 +97,10 @@ bool wxRadioBox::Enable(int n, bool enable)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::Show(int n, bool show)
|
bool wxRadioBox::Show(int n, bool show)
|
||||||
{
|
{
|
||||||
|
// TODO
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// layout parameters
|
// layout parameters
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ bool wxRadioBox::Show( bool show )
|
|||||||
|
|
||||||
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") );
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ int wxRadioBox::FindString( const wxString &find ) const
|
|||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetFocus()
|
void wxRadioBox::SetFocus()
|
||||||
@@ -497,7 +497,7 @@ void wxRadioBox::SetSelection( int n )
|
|||||||
|
|
||||||
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") );
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ int wxRadioBox::GetSelection(void) const
|
|||||||
|
|
||||||
wxFAIL_MSG( wxT("wxRadioBox none selected") );
|
wxFAIL_MSG( wxT("wxRadioBox none selected") );
|
||||||
|
|
||||||
return -1;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetString( int n ) const
|
wxString wxRadioBox::GetString( int n ) const
|
||||||
@@ -592,13 +592,13 @@ bool wxRadioBox::Enable( int item, bool enable )
|
|||||||
return true;
|
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 );
|
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() );
|
||||||
|
|
||||||
@@ -606,6 +606,8 @@ void wxRadioBox::Show( int item, bool show )
|
|||||||
gtk_widget_show( button );
|
gtk_widget_show( button );
|
||||||
else
|
else
|
||||||
gtk_widget_hide( button );
|
gtk_widget_hide( button );
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetStringSelection() const
|
wxString wxRadioBox::GetStringSelection() const
|
||||||
@@ -639,7 +641,7 @@ bool wxRadioBox::SetStringSelection( const wxString &s )
|
|||||||
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
|
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
|
||||||
|
|
||||||
int res = FindString( s );
|
int res = FindString( s );
|
||||||
if (res == -1) return false;
|
if (res == wxNOT_FOUND) return false;
|
||||||
SetSelection( res );
|
SetSelection( res );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -435,7 +435,7 @@ bool wxRadioBox::Show( bool show )
|
|||||||
|
|
||||||
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") );
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ int wxRadioBox::FindString( const wxString &find ) const
|
|||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return -1;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetFocus()
|
void wxRadioBox::SetFocus()
|
||||||
@@ -497,7 +497,7 @@ void wxRadioBox::SetSelection( int n )
|
|||||||
|
|
||||||
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") );
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
@@ -512,7 +512,7 @@ int wxRadioBox::GetSelection(void) const
|
|||||||
|
|
||||||
wxFAIL_MSG( wxT("wxRadioBox none selected") );
|
wxFAIL_MSG( wxT("wxRadioBox none selected") );
|
||||||
|
|
||||||
return -1;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetString( int n ) const
|
wxString wxRadioBox::GetString( int n ) const
|
||||||
@@ -592,13 +592,13 @@ bool wxRadioBox::Enable( int item, bool enable )
|
|||||||
return true;
|
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 );
|
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() );
|
||||||
|
|
||||||
@@ -606,6 +606,8 @@ void wxRadioBox::Show( int item, bool show )
|
|||||||
gtk_widget_show( button );
|
gtk_widget_show( button );
|
||||||
else
|
else
|
||||||
gtk_widget_hide( button );
|
gtk_widget_hide( button );
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString wxRadioBox::GetStringSelection() const
|
wxString wxRadioBox::GetStringSelection() const
|
||||||
@@ -639,7 +641,7 @@ bool wxRadioBox::SetStringSelection( const wxString &s )
|
|||||||
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
|
wxCHECK_MSG( m_widget != NULL, false, wxT("invalid radiobox") );
|
||||||
|
|
||||||
int res = FindString( s );
|
int res = FindString( s );
|
||||||
if (res == -1) return false;
|
if (res == wxNOT_FOUND) return false;
|
||||||
SetSelection( res );
|
SetSelection( res );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ wxRadioBox::~wxRadioBox()
|
|||||||
|
|
||||||
void wxRadioBox::SetString(int item, const wxString& label)
|
void wxRadioBox::SetString(int item, const wxString& label)
|
||||||
{
|
{
|
||||||
if (item < 0 || item >= m_noItems)
|
if (!IsValid(item))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Widget widget = (Widget) m_radioButtons[item];
|
Widget widget = (Widget) m_radioButtons[item];
|
||||||
@@ -204,12 +204,12 @@ int wxRadioBox::FindString(const wxString& s) const
|
|||||||
for (i = 0; i < m_noItems; i++)
|
for (i = 0; i < m_noItems; i++)
|
||||||
if (s == m_radioButtonLabels[i])
|
if (s == m_radioButtonLabels[i])
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return wxNOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxRadioBox::SetSelection(int n)
|
void wxRadioBox::SetSelection(int n)
|
||||||
{
|
{
|
||||||
if ((n < 0) || (n >= m_noItems))
|
if (!IsValid(n))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_selectedButton = n;
|
m_selectedButton = n;
|
||||||
@@ -235,7 +235,7 @@ int wxRadioBox::GetSelection() const
|
|||||||
// Find string for position
|
// Find string for position
|
||||||
wxString wxRadioBox::GetString(int n) const
|
wxString wxRadioBox::GetString(int n) const
|
||||||
{
|
{
|
||||||
if ((n < 0) || (n >= m_noItems))
|
if (!IsValid(n))
|
||||||
return wxEmptyString;
|
return wxEmptyString;
|
||||||
return m_radioButtonLabels[n];
|
return m_radioButtonLabels[n];
|
||||||
}
|
}
|
||||||
@@ -267,7 +267,7 @@ void wxRadioBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
|||||||
// Enable a specific button
|
// Enable a specific button
|
||||||
bool wxRadioBox::Enable(int n, bool enable)
|
bool wxRadioBox::Enable(int n, bool enable)
|
||||||
{
|
{
|
||||||
if ((n < 0) || (n >= m_noItems))
|
if (!IsValid(n))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable);
|
XtSetSensitive ((Widget) m_radioButtons[n], (Boolean) enable);
|
||||||
@@ -294,7 +294,7 @@ bool wxRadioBox::Show(bool show)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 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...
|
// This method isn't complete, and we try do do our best...
|
||||||
// It's main purpose isn't for allowing Show/Unshow dynamically,
|
// It's main purpose isn't for allowing Show/Unshow dynamically,
|
||||||
@@ -307,8 +307,8 @@ void wxRadioBox::Show(int n, bool show)
|
|||||||
// In my case, this is a 'direction' box, and the Show(5,False) is
|
// In my case, this is a 'direction' box, and the Show(5,False) is
|
||||||
// coupled with an Enable(5,False)
|
// coupled with an Enable(5,False)
|
||||||
//
|
//
|
||||||
if ((n < 0) || (n >= m_noItems))
|
if (!IsValid(n))
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
XtVaSetValues ((Widget) m_radioButtons[n],
|
XtVaSetValues ((Widget) m_radioButtons[n],
|
||||||
XmNindicatorOn, (unsigned char) show,
|
XmNindicatorOn, (unsigned char) show,
|
||||||
@@ -320,6 +320,8 @@ void wxRadioBox::Show(int n, bool show)
|
|||||||
// after this call!!
|
// after this call!!
|
||||||
if (!show)
|
if (!show)
|
||||||
wxRadioBox::SetString (n, " ");
|
wxRadioBox::SetString (n, " ");
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For single selection items only
|
// For single selection items only
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ int wxRadioBox::GetNumHor() const
|
|||||||
|
|
||||||
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_radioWidth[item] =
|
||||||
m_radioHeight[item] = wxDefaultCoord;
|
m_radioHeight[item] = wxDefaultCoord;
|
||||||
@@ -376,7 +376,7 @@ void wxRadioBox::SetString(int item, const wxString& label)
|
|||||||
|
|
||||||
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
|
// unselect the old button
|
||||||
if ( m_selectedButton != wxNOT_FOUND )
|
if ( m_selectedButton != wxNOT_FOUND )
|
||||||
@@ -391,7 +391,7 @@ void wxRadioBox::SetSelection(int N)
|
|||||||
// Find string for position
|
// Find string for position
|
||||||
wxString wxRadioBox::GetString(int item) const
|
wxString wxRadioBox::GetString(int item) const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( item >= 0 && item < GetCount(), wxEmptyString,
|
wxCHECK_MSG( IsValid(item), wxEmptyString,
|
||||||
wxT("invalid radiobox index") );
|
wxT("invalid radiobox index") );
|
||||||
|
|
||||||
return wxGetWindowText((*m_radioButtons)[item]);
|
return wxGetWindowText((*m_radioButtons)[item]);
|
||||||
@@ -410,20 +410,23 @@ void wxRadioBox::SetFocus()
|
|||||||
// Enable a specific button
|
// Enable a specific button
|
||||||
bool wxRadioBox::Enable(int item, bool enable)
|
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);
|
BOOL ret = ::EnableWindow((*m_radioButtons)[item], enable);
|
||||||
return true;
|
|
||||||
|
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)
|
||||||
|
|||||||
Reference in New Issue
Block a user