backported wxRESERVE_SPACE_EVEN_IF_HIDDEN to 2.8

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@52319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2008-03-04 17:46:43 +00:00
parent 98b9d9c98b
commit f891eca8c0
7 changed files with 86 additions and 7 deletions

View File

@@ -118,6 +118,8 @@ All (GUI):
- Added alpha support to wxImage::Paste() (Steven Van Ingelgem) - Added alpha support to wxImage::Paste() (Steven Van Ingelgem)
- Use current date when opening popup in generic wxDatePickerCtrl. - Use current date when opening popup in generic wxDatePickerCtrl.
- Remove associated help text from wxHelpProvider when a window is destroyed. - Remove associated help text from wxHelpProvider when a window is destroyed.
- Added wxSizerFlags::ReserveSpaceEvenIfHidden() and
wxRESERVE_SPACE_EVEN_IF_HIDDEN sizer flag.
All (Unix): All (Unix):

View File

@@ -139,6 +139,11 @@ use that size to calculate the layout. This allows layouts to
adjust when an item changes and its \arg{best size} becomes adjust when an item changes and its \arg{best size} becomes
different. If you would rather have a window item stay the size it different. If you would rather have a window item stay the size it
started with then use wxFIXED\_MINSIZE.} started with then use wxFIXED\_MINSIZE.}
\twocolitem{\windowstyle{wxRESERVE\_SPACE\_EVEN\_IF\_HIDDEN}}{Normally wxSizers
don't allocate space for hidden windows or other items. This flag overrides
this behavior so that sufficient space is allocated for the window even if it
isn't visible. This makes it possible to dynamically show and hide controls
without resizing parent dialog, for example. \newsince{2.8.8}}
\twocolitem{\windowstyle{wxALIGN\_CENTER wxALIGN\_CENTRE}\\ \twocolitem{\windowstyle{wxALIGN\_CENTER wxALIGN\_CENTRE}\\
\windowstyle{wxALIGN\_LEFT}\\ \windowstyle{wxALIGN\_LEFT}\\
\windowstyle{wxALIGN\_RIGHT}\\ \windowstyle{wxALIGN\_RIGHT}\\
@@ -685,6 +690,17 @@ the window should be also set as its minimal size.
Sets the proportion of this wxSizerFlags to \arg{proportion} Sets the proportion of this wxSizerFlags to \arg{proportion}
\membersection{wxSizerFlags::ReserveSpaceEvenIfHidden}\label{wxsizerflagsreservespaceevenifhidden}
\func{wxSizerFlags\& }{ReserveSpaceEvenIfHidden}{\void}
Set the \texttt{wxRESERVE\_SPACE\_EVEN\_IF\_HIDDEN} flag. Normally wxSizers
don't allocate space for hidden windows or other items. This flag overrides
this behavior so that sufficient space is allocated for the window even if it
isn't visible. This makes it possible to dynamically show and hide controls
without resizing parent dialog, for example. \newsince{2.8.8}
\membersection{wxSizerFlags::Right}\label{wxsizerflagsright} \membersection{wxSizerFlags::Right}\label{wxsizerflagsright}
\func{wxSizerFlags\& }{Right}{\void} \func{wxSizerFlags\& }{Right}{\void}

View File

@@ -1273,6 +1273,9 @@ enum wxStretch
wxEXPAND = wxGROW, wxEXPAND = wxGROW,
wxSHAPED = 0x4000, wxSHAPED = 0x4000,
wxFIXED_MINSIZE = 0x8000, wxFIXED_MINSIZE = 0x8000,
#if wxABI_VERSION >= 20808
wxRESERVE_SPACE_EVEN_IF_HIDDEN = 0x0002,
#endif
wxTILE = 0xc000, wxTILE = 0xc000,
/* for compatibility only, default now, don't use explicitly any more */ /* for compatibility only, default now, don't use explicitly any more */

View File

@@ -24,6 +24,8 @@ class WXDLLIMPEXP_FWD_CORE wxButton;
class WXDLLIMPEXP_FWD_CORE wxBoxSizer; class WXDLLIMPEXP_FWD_CORE wxBoxSizer;
class WXDLLIMPEXP_FWD_CORE wxSizerItem; class WXDLLIMPEXP_FWD_CORE wxSizerItem;
class WXDLLIMPEXP_FWD_CORE wxSizer; class WXDLLIMPEXP_FWD_CORE wxSizer;
class WXDLLIMPEXP_FWD_CORE wxFlexGridSizer;
class WXDLLIMPEXP_FWD_CORE wxGridBagSizer;
#ifndef wxUSE_BORDER_BY_DEFAULT #ifndef wxUSE_BORDER_BY_DEFAULT
#ifdef __SMARTPHONE__ #ifdef __SMARTPHONE__
@@ -175,6 +177,11 @@ public:
} }
#endif // wx 2.8.2+ #endif // wx 2.8.2+
#if wxABI_VERSION >= 20808
// makes the item ignore window's visibility status
wxSizerFlags& ReserveSpaceEvenIfHidden();
#endif
// accessors for wxSizer only // accessors for wxSizer only
int GetProportion() const { return m_proportion; } int GetProportion() const { return m_proportion; }
int GetFlags() const { return m_flags; } int GetFlags() const { return m_flags; }
@@ -393,8 +400,15 @@ protected:
wxObject *m_userData; wxObject *m_userData;
private: private:
// 2.8-only implementation detail for wxRESERVE_SPACE_EVEN_IF_HIDDEN
bool ShouldAccountFor() const;
DECLARE_CLASS(wxSizerItem) DECLARE_CLASS(wxSizerItem)
DECLARE_NO_COPY_CLASS(wxSizerItem) DECLARE_NO_COPY_CLASS(wxSizerItem)
friend class wxBoxSizer;
friend class wxFlexGridSizer;
friend class wxGridBagSizer;
}; };
WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList ); WX_DECLARE_EXPORTED_LIST( wxSizerItem, wxSizerItemList );

View File

@@ -453,7 +453,7 @@ wxSize wxGridBagSizer::CalcMin()
while (node) while (node)
{ {
wxGBSizerItem* item = (wxGBSizerItem*)node->GetData(); wxGBSizerItem* item = (wxGBSizerItem*)node->GetData();
if ( item->IsShown() ) if ( item->ShouldAccountFor() )
{ {
int row, col, endrow, endcol; int row, col, endrow, endcol;
@@ -538,7 +538,7 @@ void wxGridBagSizer::RecalcSizes()
int row, col, endrow, endcol; int row, col, endrow, endcol;
wxGBSizerItem* item = (wxGBSizerItem*)node->GetData(); wxGBSizerItem* item = (wxGBSizerItem*)node->GetData();
if ( item->IsShown() ) if ( item->ShouldAccountFor() )
{ {
item->GetPos(row, col); item->GetPos(row, col);
item->GetEndPos(endrow, endcol); item->GetEndPos(endrow, endcol);

View File

@@ -86,6 +86,17 @@ WX_DEFINE_EXPORTED_LIST( wxSizerItemList )
minsize minsize
*/ */
// ----------------------------------------------------------------------------
// wxSizerFlags
// ----------------------------------------------------------------------------
wxSizerFlags& wxSizerFlags::ReserveSpaceEvenIfHidden()
{
m_flags |= wxRESERVE_SPACE_EVEN_IF_HIDDEN;
return *this;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxSizerItem // wxSizerItem
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -487,6 +498,37 @@ bool wxSizerItem::IsShown() const
return false; return false;
} }
// This is a helper to support wxRESERVE_SPACE_EVEN_IF_HIDDEN. In wx 2.9+,
// this flag is respected by IsShown(), but not in wx 2.8.
bool wxSizerItem::ShouldAccountFor() const
{
if ( m_flag & wxRESERVE_SPACE_EVEN_IF_HIDDEN )
return true;
if ( IsSizer() )
{
// this mirrors wxSizerItem::IsShown() code above
const wxSizerItemList& children = m_sizer->GetChildren();
if ( children.GetCount() == 0 )
return true;
for ( wxSizerItemList::compatibility_iterator
node = children.GetFirst();
node;
node = node->GetNext() )
{
if ( node->GetData()->ShouldAccountFor() )
return true;
}
return false;
}
else
{
return IsShown();
}
}
#if WXWIN_COMPATIBILITY_2_6 #if WXWIN_COMPATIBILITY_2_6
void wxSizerItem::SetOption( int option ) void wxSizerItem::SetOption( int option )
{ {
@@ -1415,7 +1457,7 @@ wxSize wxFlexGridSizer::CalcMin()
while (node) while (node)
{ {
wxSizerItem *item = node->GetData(); wxSizerItem *item = node->GetData();
if ( item->IsShown() ) if ( item->ShouldAccountFor() )
{ {
wxSize sz( item->CalcMin() ); wxSize sz( item->CalcMin() );
int row = i / ncols; int row = i / ncols;
@@ -1660,7 +1702,7 @@ void wxBoxSizer::RecalcSizes()
{ {
wxSizerItem *item = node->GetData(); wxSizerItem *item = node->GetData();
if (item->IsShown()) if (item->ShouldAccountFor())
{ {
wxSize size( item->GetMinSizeWithBorder() ); wxSize size( item->GetMinSizeWithBorder() );
@@ -1753,7 +1795,7 @@ wxSize wxBoxSizer::CalcMin()
{ {
wxSizerItem *item = node->GetData(); wxSizerItem *item = node->GetData();
if ( item->IsShown() ) if ( item->ShouldAccountFor() )
{ {
item->CalcMin(); // result is stored in the item item->CalcMin(); // result is stored in the item
@@ -1771,7 +1813,7 @@ wxSize wxBoxSizer::CalcMin()
{ {
wxSizerItem *item = node->GetData(); wxSizerItem *item = node->GetData();
if (item->IsShown() && item->GetProportion() != 0) if (item->ShouldAccountFor() && item->GetProportion() != 0)
{ {
int stretch = item->GetProportion(); int stretch = item->GetProportion();
wxSize size( item->GetMinSizeWithBorder() ); wxSize size( item->GetMinSizeWithBorder() );
@@ -1797,7 +1839,7 @@ wxSize wxBoxSizer::CalcMin()
{ {
wxSizerItem *item = node->GetData(); wxSizerItem *item = node->GetData();
if (item->IsShown()) if (item->ShouldAccountFor())
{ {
wxSize size( item->GetMinSizeWithBorder() ); wxSize size( item->GetMinSizeWithBorder() );
if (item->GetProportion() != 0) if (item->GetProportion() != 0)

View File

@@ -37,6 +37,8 @@
*wxRichTextCtrl*SetTextCursor*; *wxRichTextCtrl*SetTextCursor*;
*wxRichTextCtrl*SetURLCursor*; *wxRichTextCtrl*SetURLCursor*;
*wxScrollHelper*HandleOnChildFocus*; *wxScrollHelper*HandleOnChildFocus*;
*wxSizerFlags*ReserveSpaceEvenIfHidden*;
*wxSizerItem*ShouldAccountFor*;
*wxWindowBase*Get*Sibling*; *wxWindowBase*Get*Sibling*;
}; };