Recursive wxSizer::Show for subsizer and return value if element was found.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29120 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -207,7 +207,6 @@ All:
|
|||||||
- added wxMicroSleep() and wxMilliSleep() replacing deprecated wxUsleep()
|
- added wxMicroSleep() and wxMilliSleep() replacing deprecated wxUsleep()
|
||||||
- basic UDP sockets support (Lenny Maiorani)
|
- basic UDP sockets support (Lenny Maiorani)
|
||||||
- fixed wxDateTime::GetWeekDayName() for some dates (Daniel Kaps)
|
- fixed wxDateTime::GetWeekDayName() for some dates (Daniel Kaps)
|
||||||
- support for comma in contrib gizmo wxLEDNumberCtrl (Grant Likely)
|
|
||||||
- deprecated wxDateTime::SetToTheWeek() in favour of SetToWeekOfYear()
|
- deprecated wxDateTime::SetToTheWeek() in favour of SetToWeekOfYear()
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
@@ -226,6 +225,8 @@ All (GUI):
|
|||||||
- added samples/splash
|
- added samples/splash
|
||||||
- added support for stock buttons
|
- added support for stock buttons
|
||||||
- added wxTopLevelWindow::RequestUserAttention()
|
- added wxTopLevelWindow::RequestUserAttention()
|
||||||
|
- support for comma in contrib gizmo wxLEDNumberCtrl (Grant Likely)
|
||||||
|
- recursive wxSizer::Show for subsizer and return value if element was found
|
||||||
|
|
||||||
Unix:
|
Unix:
|
||||||
|
|
||||||
|
@@ -391,14 +391,17 @@ minimal size. For windows with managed scrollbars this will set them appropriate
|
|||||||
|
|
||||||
\membersection{wxSizer::Show}\label{wxsizershow}
|
\membersection{wxSizer::Show}\label{wxsizershow}
|
||||||
|
|
||||||
\func{void}{Show}{\param{wxWindow* }{window}, \param{bool }{show = true}}
|
\func{bool}{Show}{\param{wxWindow* }{window}, \param{bool }{show = true}, \param{bool }{recursive = false}}
|
||||||
|
|
||||||
\func{void}{Show}{\param{wxSizer* }{sizer}, \param{bool }{show = true}}
|
\func{bool}{Show}{\param{wxSizer* }{sizer}, \param{bool }{show = true}, \param{bool }{recursive = false}}
|
||||||
|
|
||||||
\func{void}{Show}{\param{size\_t }{index}, \param{bool }{show = true}}
|
\func{bool}{Show}{\param{size\_t }{index}, \param{bool }{show = true}}
|
||||||
|
|
||||||
Shows or hides the {\it window}, {\it sizer}, or item at {\it index}.
|
Shows or hides the {\it window}, {\it sizer}, or item at {\it index}.
|
||||||
To make a sizer item disappear or reappear, use Show() followed by Layout().
|
To make a sizer item disappear or reappear, use Show() followed by Layout().
|
||||||
|
Use parameter {\it recursive} to show or hide elements found in subsizers.
|
||||||
|
|
||||||
|
Returns true if the child item was found, false otherwise.
|
||||||
|
|
||||||
Note that this only works with wxBoxSizer and wxFlexGridSizer, since they
|
Note that this only works with wxBoxSizer and wxFlexGridSizer, since they
|
||||||
are the only two sizer classes that can size rows/columns independently.
|
are the only two sizer classes that can size rows/columns independently.
|
||||||
|
@@ -80,10 +80,10 @@ public:
|
|||||||
void SetMinSize(const wxSize& size)
|
void SetMinSize(const wxSize& size)
|
||||||
{
|
{
|
||||||
if (IsWindow()) m_window->SetMinSize(size);
|
if (IsWindow()) m_window->SetMinSize(size);
|
||||||
m_minSize = size;
|
m_minSize = size;
|
||||||
}
|
}
|
||||||
void SetMinSize( int x, int y )
|
void SetMinSize( int x, int y )
|
||||||
{ SetMinSize(wxSize(x, y)); }
|
{ SetMinSize(wxSize(x, y)); }
|
||||||
void SetInitSize( int x, int y )
|
void SetInitSize( int x, int y )
|
||||||
{ SetMinSize(wxSize(x, y)); }
|
{ SetMinSize(wxSize(x, y)); }
|
||||||
|
|
||||||
@@ -308,16 +308,16 @@ public:
|
|||||||
|
|
||||||
// Manage whether individual scene items are considered
|
// Manage whether individual scene items are considered
|
||||||
// in the layout calculations or not.
|
// in the layout calculations or not.
|
||||||
void Show( wxWindow *window, bool show = true );
|
bool Show( wxWindow *window, bool show = true, bool recursive = false );
|
||||||
void Show( wxSizer *sizer, bool show = true );
|
bool Show( wxSizer *sizer, bool show = true, bool recursive = false );
|
||||||
void Show( size_t index, bool show = true );
|
bool Show( size_t index, bool show = true );
|
||||||
|
|
||||||
void Hide( wxSizer *sizer )
|
bool Hide( wxSizer *sizer, bool recursive = false )
|
||||||
{ Show( sizer, false ); }
|
{ return Show( sizer, false, recursive ); }
|
||||||
void Hide( wxWindow *window )
|
bool Hide( wxWindow *window, bool recursive = false )
|
||||||
{ Show( window, false ); }
|
{ return Show( window, false, recursive ); }
|
||||||
void Hide( size_t index )
|
bool Hide( size_t index )
|
||||||
{ Show( index, false ); }
|
{ return Show( index, false ); }
|
||||||
|
|
||||||
bool IsShown( wxWindow *window ) const;
|
bool IsShown( wxWindow *window ) const;
|
||||||
bool IsShown( wxSizer *sizer ) const;
|
bool IsShown( wxSizer *sizer ) const;
|
||||||
@@ -435,7 +435,7 @@ public:
|
|||||||
// Read-only access to the row heights and col widths arrays
|
// Read-only access to the row heights and col widths arrays
|
||||||
const wxArrayInt& GetRowHeights() const { return m_rowHeights; }
|
const wxArrayInt& GetRowHeights() const { return m_rowHeights; }
|
||||||
const wxArrayInt& GetColWidths() const { return m_colWidths; }
|
const wxArrayInt& GetColWidths() const { return m_colWidths; }
|
||||||
|
|
||||||
// implementation
|
// implementation
|
||||||
virtual void RecalcSizes();
|
virtual void RecalcSizes();
|
||||||
virtual wxSize CalcMin();
|
virtual wxSize CalcMin();
|
||||||
@@ -444,7 +444,7 @@ protected:
|
|||||||
void AdjustForFlexDirection();
|
void AdjustForFlexDirection();
|
||||||
void AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
|
void AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
|
||||||
int nrows, int ncols);
|
int nrows, int ncols);
|
||||||
|
|
||||||
// the heights/widths of all rows/columns
|
// the heights/widths of all rows/columns
|
||||||
wxArrayInt m_rowHeights,
|
wxArrayInt m_rowHeights,
|
||||||
m_colWidths;
|
m_colWidths;
|
||||||
@@ -553,7 +553,7 @@ public:
|
|||||||
wxDEPRECATED( wxBookCtrlSizer(wxBookCtrl *bookctrl) );
|
wxDEPRECATED( wxBookCtrlSizer(wxBookCtrl *bookctrl) );
|
||||||
|
|
||||||
wxBookCtrl *GetControl() const { return m_bookctrl; }
|
wxBookCtrl *GetControl() const { return m_bookctrl; }
|
||||||
|
|
||||||
virtual void RecalcSizes();
|
virtual void RecalcSizes();
|
||||||
virtual wxSize CalcMin();
|
virtual wxSize CalcMin();
|
||||||
|
|
||||||
@@ -561,7 +561,7 @@ protected:
|
|||||||
// this protected ctor lets us mark the real one above as deprecated
|
// this protected ctor lets us mark the real one above as deprecated
|
||||||
// and still have warning-free build of the library itself:
|
// and still have warning-free build of the library itself:
|
||||||
wxBookCtrlSizer() {}
|
wxBookCtrlSizer() {}
|
||||||
|
|
||||||
wxBookCtrl *m_bookctrl;
|
wxBookCtrl *m_bookctrl;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -47,35 +47,35 @@ IMPLEMENT_CLASS(wxStaticBoxSizer, wxBoxSizer)
|
|||||||
WX_DEFINE_EXPORTED_LIST( wxSizerItemList );
|
WX_DEFINE_EXPORTED_LIST( wxSizerItemList );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO PROPERTIES
|
TODO PROPERTIES
|
||||||
sizeritem
|
sizeritem
|
||||||
object
|
object
|
||||||
object_ref
|
object_ref
|
||||||
minsize
|
minsize
|
||||||
option
|
option
|
||||||
flag
|
flag
|
||||||
border
|
border
|
||||||
spacer
|
spacer
|
||||||
option
|
option
|
||||||
flag
|
flag
|
||||||
borfder
|
borfder
|
||||||
boxsizer
|
boxsizer
|
||||||
orient
|
orient
|
||||||
staticboxsizer
|
staticboxsizer
|
||||||
orient
|
orient
|
||||||
label
|
label
|
||||||
gridsizer
|
gridsizer
|
||||||
rows
|
rows
|
||||||
cols
|
cols
|
||||||
vgap
|
vgap
|
||||||
hgap
|
hgap
|
||||||
flexgridsizer
|
flexgridsizer
|
||||||
rows
|
rows
|
||||||
cols
|
cols
|
||||||
vgap
|
vgap
|
||||||
hgap
|
hgap
|
||||||
growablerows
|
growablerows
|
||||||
growablecols
|
growablecols
|
||||||
minsize
|
minsize
|
||||||
*/
|
*/
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
@@ -108,7 +108,7 @@ wxSizerItem::wxSizerItem( wxWindow *window, int proportion, int flag, int border
|
|||||||
if (flag & wxFIXED_MINSIZE)
|
if (flag & wxFIXED_MINSIZE)
|
||||||
window->SetMinSize(window->GetSize());
|
window->SetMinSize(window->GetSize());
|
||||||
m_minSize = window->GetSize();
|
m_minSize = window->GetSize();
|
||||||
|
|
||||||
// aspect ratio calculated from initial size
|
// aspect ratio calculated from initial size
|
||||||
SetRatio( m_minSize );
|
SetRatio( m_minSize );
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ wxSize wxSizerItem::GetMinSizeWithBorder() const
|
|||||||
ret.y += m_border;
|
ret.y += m_border;
|
||||||
if (m_flag & wxSOUTH)
|
if (m_flag & wxSOUTH)
|
||||||
ret.y += m_border;
|
ret.y += m_border;
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -858,7 +858,7 @@ bool wxSizer::DoSetItemMinSize( size_t index, int width, int height )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSizer::Show( wxWindow *window, bool show )
|
bool wxSizer::Show( wxWindow *window, bool show, bool recursive )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( window, _T("Show for NULL window") );
|
wxASSERT_MSG( window, _T("Show for NULL window") );
|
||||||
|
|
||||||
@@ -870,13 +870,22 @@ void wxSizer::Show( wxWindow *window, bool show )
|
|||||||
if (item->GetWindow() == window)
|
if (item->GetWindow() == window)
|
||||||
{
|
{
|
||||||
item->Show( show );
|
item->Show( show );
|
||||||
break;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (recursive && item->IsSizer())
|
||||||
|
{
|
||||||
|
if (item->GetSizer()->Show(window, show, recursive))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSizer::Show( wxSizer *sizer, bool show )
|
bool wxSizer::Show( wxSizer *sizer, bool show, bool recursive )
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( sizer, _T("Show for NULL sizer") );
|
wxASSERT_MSG( sizer, _T("Show for NULL sizer") );
|
||||||
|
|
||||||
@@ -888,18 +897,30 @@ void wxSizer::Show( wxSizer *sizer, bool show )
|
|||||||
if (item->GetSizer() == sizer)
|
if (item->GetSizer() == sizer)
|
||||||
{
|
{
|
||||||
item->Show( show );
|
item->Show( show );
|
||||||
break;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (recursive && item->IsSizer())
|
||||||
|
{
|
||||||
|
if (item->GetSizer()->Show(sizer, show, recursive))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
node = node->GetNext();
|
node = node->GetNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSizer::Show( size_t index, bool show )
|
bool wxSizer::Show( size_t index, bool show)
|
||||||
{
|
{
|
||||||
wxCHECK_RET( index < m_children.GetCount(),
|
wxCHECK_MSG( index < m_children.GetCount(),
|
||||||
|
false,
|
||||||
_T("Show index is out of range") );
|
_T("Show index is out of range") );
|
||||||
|
|
||||||
m_children.Item( index )->GetData()->Show( show );
|
m_children.Item( index )->GetData()->Show( show );
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxSizer::ShowItems( bool show )
|
void wxSizer::ShowItems( bool show )
|
||||||
@@ -1072,7 +1093,7 @@ wxSize wxGridSizer::CalcMin()
|
|||||||
void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h )
|
void wxGridSizer::SetItemBounds( wxSizerItem *item, int x, int y, int w, int h )
|
||||||
{
|
{
|
||||||
wxPoint pt( x,y );
|
wxPoint pt( x,y );
|
||||||
wxSize sz( item->GetMinSizeWithBorder() );
|
wxSize sz( item->GetMinSizeWithBorder() );
|
||||||
int flag = item->GetFlag();
|
int flag = item->GetFlag();
|
||||||
|
|
||||||
if ((flag & wxEXPAND) || (flag & wxSHAPED))
|
if ((flag & wxEXPAND) || (flag & wxSHAPED))
|
||||||
@@ -1206,7 +1227,7 @@ wxSize wxFlexGridSizer::CalcMin()
|
|||||||
}
|
}
|
||||||
|
|
||||||
AdjustForFlexDirection();
|
AdjustForFlexDirection();
|
||||||
|
|
||||||
// Sum total minimum size, including gaps between rows/columns.
|
// Sum total minimum size, including gaps between rows/columns.
|
||||||
// -1 is used as a magic number meaning empty column.
|
// -1 is used as a magic number meaning empty column.
|
||||||
int width = 0;
|
int width = 0;
|
||||||
@@ -1250,7 +1271,7 @@ void wxFlexGridSizer::AdjustForFlexDirection()
|
|||||||
array[n] = largest;
|
array[n] = largest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
|
void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
|
||||||
@@ -1270,7 +1291,7 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
|
|||||||
// requested growable rows/columns are still valid.
|
// requested growable rows/columns are still valid.
|
||||||
if (m_growableRows[idx] >= nrows)
|
if (m_growableRows[idx] >= nrows)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If all items in a row/column are hidden, that row/column will
|
// If all items in a row/column are hidden, that row/column will
|
||||||
// have a dimension of -1. This causes the row/column to be
|
// have a dimension of -1. This causes the row/column to be
|
||||||
// hidden completely.
|
// hidden completely.
|
||||||
@@ -1322,7 +1343,7 @@ void wxFlexGridSizer::AdjustForGrowables(const wxSize& sz, const wxSize& minsz,
|
|||||||
// requested growable rows/columns are still valid.
|
// requested growable rows/columns are still valid.
|
||||||
if (m_growableCols[idx] >= ncols)
|
if (m_growableCols[idx] >= ncols)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// If all items in a row/column are hidden, that row/column will
|
// If all items in a row/column are hidden, that row/column will
|
||||||
// have a dimension of -1. This causes the column to be hidden
|
// have a dimension of -1. This causes the column to be hidden
|
||||||
// completely.
|
// completely.
|
||||||
@@ -1494,7 +1515,7 @@ wxSize wxBoxSizer::CalcMin()
|
|||||||
|
|
||||||
if (item->IsShown())
|
if (item->IsShown())
|
||||||
item->CalcMin(); // result is stored in the item
|
item->CalcMin(); // result is stored in the item
|
||||||
|
|
||||||
if (item->IsShown() && item->GetProportion() != 0)
|
if (item->IsShown() && item->GetProportion() != 0)
|
||||||
m_stretchable += item->GetProportion();
|
m_stretchable += item->GetProportion();
|
||||||
|
|
||||||
@@ -1514,7 +1535,7 @@ wxSize wxBoxSizer::CalcMin()
|
|||||||
int stretch = item->GetProportion();
|
int stretch = item->GetProportion();
|
||||||
wxSize size( item->GetMinSizeWithBorder() );
|
wxSize size( item->GetMinSizeWithBorder() );
|
||||||
int minSize;
|
int minSize;
|
||||||
|
|
||||||
// Integer division rounded up is (a + b - 1) / b
|
// Integer division rounded up is (a + b - 1) / b
|
||||||
// Round up needed in order to guarantee that all
|
// Round up needed in order to guarantee that all
|
||||||
// all items will have size not less then their min size
|
// all items will have size not less then their min size
|
||||||
@@ -1522,7 +1543,7 @@ wxSize wxBoxSizer::CalcMin()
|
|||||||
minSize = ( size.x*m_stretchable + stretch - 1)/stretch;
|
minSize = ( size.x*m_stretchable + stretch - 1)/stretch;
|
||||||
else
|
else
|
||||||
minSize = ( size.y*m_stretchable + stretch - 1)/stretch;
|
minSize = ( size.y*m_stretchable + stretch - 1)/stretch;
|
||||||
|
|
||||||
if (minSize > maxMinSize)
|
if (minSize > maxMinSize)
|
||||||
maxMinSize = minSize;
|
maxMinSize = minSize;
|
||||||
}
|
}
|
||||||
@@ -1614,7 +1635,7 @@ static void GetStaticBoxBorders( wxStaticBox *box,
|
|||||||
// pixels (otherwise overlapping occurs at the top). The "other"
|
// pixels (otherwise overlapping occurs at the top). The "other"
|
||||||
// border has to be 11.
|
// border has to be 11.
|
||||||
extraTop = 11;
|
extraTop = 11;
|
||||||
other = 11;
|
other = 11;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user