Fix display of empty wxStaticBoxSizers.
wxStaticBoxSizer should be considered shown if its static box is shown, even if it has no elements (or all of them are hidden). Closes #14698. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73729 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -715,6 +715,10 @@ public:
|
|||||||
|
|
||||||
void Show(bool show) { ShowItems(show); }
|
void Show(bool show) { ShowItems(show); }
|
||||||
|
|
||||||
|
// This is the ShowItems() counterpart and returns true if any of the sizer
|
||||||
|
// items are shown.
|
||||||
|
virtual bool AreAnyItemsShown() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxSize m_size;
|
wxSize m_size;
|
||||||
wxSize m_minSize;
|
wxSize m_minSize;
|
||||||
@@ -1033,6 +1037,7 @@ public:
|
|||||||
|
|
||||||
// override to hide/show the static box as well
|
// override to hide/show the static box as well
|
||||||
virtual void ShowItems (bool show);
|
virtual void ShowItems (bool show);
|
||||||
|
virtual bool AreAnyItemsShown() const;
|
||||||
|
|
||||||
virtual bool Detach( wxWindow *window );
|
virtual bool Detach( wxWindow *window );
|
||||||
virtual bool Detach( wxSizer *sizer ) { return wxBoxSizer::Detach(sizer); }
|
virtual bool Detach( wxSizer *sizer ) { return wxBoxSizer::Detach(sizer); }
|
||||||
|
@@ -602,20 +602,10 @@ bool wxSizerItem::IsShown() const
|
|||||||
return m_window->IsShown();
|
return m_window->IsShown();
|
||||||
|
|
||||||
case Item_Sizer:
|
case Item_Sizer:
|
||||||
{
|
|
||||||
// arbitrarily decide that if at least one of our elements is
|
// arbitrarily decide that if at least one of our elements is
|
||||||
// shown, so are we (this arbitrariness is the reason for
|
// shown, so are we (this arbitrariness is the reason for
|
||||||
// deprecating this function)
|
// deprecating this function)
|
||||||
for ( wxSizerItemList::compatibility_iterator
|
return m_sizer->AreAnyItemsShown();
|
||||||
node = m_sizer->GetChildren().GetFirst();
|
|
||||||
node;
|
|
||||||
node = node->GetNext() )
|
|
||||||
{
|
|
||||||
if ( node->GetData()->IsShown() )
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Item_Spacer:
|
case Item_Spacer:
|
||||||
return m_spacer->IsShown();
|
return m_spacer->IsShown();
|
||||||
@@ -1290,6 +1280,19 @@ void wxSizer::ShowItems( bool show )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxSizer::AreAnyItemsShown() const
|
||||||
|
{
|
||||||
|
wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
|
||||||
|
while (node)
|
||||||
|
{
|
||||||
|
if ( node->GetData()->IsShown() )
|
||||||
|
return true;
|
||||||
|
node = node->GetNext();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxSizer::IsShown( wxWindow *window ) const
|
bool wxSizer::IsShown( wxWindow *window ) const
|
||||||
{
|
{
|
||||||
wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
|
wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
|
||||||
@@ -2541,6 +2544,16 @@ void wxStaticBoxSizer::ShowItems( bool show )
|
|||||||
wxBoxSizer::ShowItems( show );
|
wxBoxSizer::ShowItems( show );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxStaticBoxSizer::AreAnyItemsShown() const
|
||||||
|
{
|
||||||
|
// We don't need to check the status of our child items: if the box is
|
||||||
|
// shown, this sizer should be considered shown even if all its elements
|
||||||
|
// are hidden (or, more prosaically, there are no elements at all). And,
|
||||||
|
// conversely, if the box is hidden then all our items, which are its
|
||||||
|
// children, are hidden too.
|
||||||
|
return m_staticBox->IsShown();
|
||||||
|
}
|
||||||
|
|
||||||
bool wxStaticBoxSizer::Detach( wxWindow *window )
|
bool wxStaticBoxSizer::Detach( wxWindow *window )
|
||||||
{
|
{
|
||||||
// avoid deleting m_staticBox in our dtor if it's being detached from the
|
// avoid deleting m_staticBox in our dtor if it's being detached from the
|
||||||
|
Reference in New Issue
Block a user