Parts of wxSizer::Show() extracted into wxSizer::GetItem() (together with documentation).

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29884 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba 2004-10-15 18:58:52 +00:00
parent 15513a8066
commit 9f13661f8b
4 changed files with 85 additions and 30 deletions

View File

@ -205,6 +205,7 @@ OTHER CHANGES
All:
- Norvegian (Bokmål) translation added (Hans F. Nordhaug)
- recursive wxSizer::GetItem returns item of given window, sizer or nth index
Unix:

View File

@ -214,6 +214,21 @@ windows which manage it.
\helpref{wxSizer::SetVirtualSizeHints}{wxsizersetvirtualsizehints}
\membersection{wxSizer::GetItem}\label{wxsizergetitem}
\func{wxSizerItem *}{GetItem}{\param{wxWindow* }{window}, \param{bool }{recursive = false}}
\func{wxSizerItem *}{GetItem}{\param{wxSizer* }{sizer}, \param{bool }{recursive = false}}
\func{wxSizerItem *}{GetItem}{\param{size\_t }{index}}
Finds item of the sizer which holds given {\it window}, {\it sizer} or is located
in sizer at position {\it index}.
Use parameter {\it recursive} to search in subsizers too.
Returns pointer to item or NULL.
\membersection{wxSizer::GetSize}\label{wxsizergetsize}
\func{wxSize}{GetSize}{\void}

View File

@ -408,6 +408,10 @@ public:
void SetDimension( int x, int y, int width, int height );
wxSizerItem* GetItem( wxWindow *window, bool recursive = false );
wxSizerItem* GetItem( wxSizer *sizer, bool recursive = false );
wxSizerItem* GetItem( size_t index );
// Manage whether individual scene items are considered
// in the layout calculations or not.
bool Show( wxWindow *window, bool show = true, bool recursive = false );

View File

@ -760,9 +760,9 @@ bool wxSizer::DoSetItemMinSize( size_t index, int width, int height )
return true;
}
bool wxSizer::Show( wxWindow *window, bool show, bool recursive )
wxSizerItem* wxSizer::GetItem( wxWindow *window, bool recursive )
{
wxASSERT_MSG( window, _T("Show for NULL window") );
wxASSERT_MSG( window, _T("GetItem for NULL window") );
wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
while (node)
@ -771,25 +771,24 @@ bool wxSizer::Show( wxWindow *window, bool show, bool recursive )
if (item->GetWindow() == window)
{
item->Show( show );
return true;
return item;
}
else if (recursive && item->IsSizer())
{
if (item->GetSizer()->Show(window, show, recursive))
return true;
wxSizerItem *subitem = item->GetSizer()->GetItem( window, true );
if (subitem)
return subitem;
}
node = node->GetNext();
}
return false;
return NULL;
}
bool wxSizer::Show( wxSizer *sizer, bool show, bool recursive )
wxSizerItem* wxSizer::GetItem( wxSizer *sizer, bool recursive )
{
wxASSERT_MSG( sizer, _T("Show for NULL sizer") );
wxASSERT_MSG( sizer, _T("GetItem for NULL sizer") );
wxSizerItemList::compatibility_iterator node = m_children.GetFirst();
while (node)
@ -798,31 +797,67 @@ bool wxSizer::Show( wxSizer *sizer, bool show, bool recursive )
if (item->GetSizer() == sizer)
{
item->Show( show );
return true;
return item;
}
else if (recursive && item->IsSizer())
{
if (item->GetSizer()->Show(sizer, show, recursive))
return true;
wxSizerItem *subitem = item->GetSizer()->GetItem( sizer, true );
if (subitem)
return subitem;
}
node = node->GetNext();
}
return NULL;
}
wxSizerItem* wxSizer::GetItem( size_t index )
{
wxCHECK_MSG( index < m_children.GetCount(),
NULL,
_T("GetItem index is out of range") );
return m_children.Item( index )->GetData();
}
bool wxSizer::Show( wxWindow *window, bool show, bool recursive )
{
wxSizerItem *item = GetItem( window, recursive );
if ( item )
{
item->Show( show );
return true;
}
return false;
}
bool wxSizer::Show( wxSizer *sizer, bool show, bool recursive )
{
wxSizerItem *item = GetItem( sizer, recursive );
if ( item )
{
item->Show( show );
return true;
}
return false;
}
bool wxSizer::Show( size_t index, bool show)
{
wxCHECK_MSG( index < m_children.GetCount(),
false,
_T("Show index is out of range") );
m_children.Item( index )->GetData()->Show( show );
wxSizerItem *item = GetItem( index );
if ( item )
{
item->Show( show );
return true;
}
return false;
}
void wxSizer::ShowItems( bool show )