From 0ba6faaeeeec36fe4e6fc376f2f5edc1c0d34334 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Tue, 4 Mar 2008 12:01:36 +0000 Subject: [PATCH] added wxRESERVE_SPACE_EVEN_IF_HIDDEN sizer flag that prevents the sizer from changing size if a window is hidden git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52309 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 29 +++++++++++++++++++++++------ include/wx/sizer.h | 13 +++++++++++-- src/common/sizer.cpp | 3 +++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/include/wx/defs.h b/include/wx/defs.h index 0c278d4f32..c48dbaa91f 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -1409,7 +1409,10 @@ enum wxOrientation wxHORIZONTAL = 0x0004, wxVERTICAL = 0x0008, - wxBOTH = wxVERTICAL | wxHORIZONTAL + wxBOTH = wxVERTICAL | wxHORIZONTAL, + + /* a mask to extract orientation from the combination of flags */ + wxORIENTATION_MASK = wxBOTH }; enum wxDirection @@ -1427,7 +1430,10 @@ enum wxDirection wxWEST = wxLEFT, wxEAST = wxRIGHT, - wxALL = (wxUP | wxDOWN | wxRIGHT | wxLEFT) + wxALL = (wxUP | wxDOWN | wxRIGHT | wxLEFT), + + /* a mask to extract direction from the combination of flags */ + wxDIRECTION_MASK = wxALL }; enum wxAlignment @@ -1449,20 +1455,31 @@ enum wxAlignment wxALIGN_MASK = 0x0f00 }; -enum wxStretch +/* misc. flags for wxSizer items */ +enum wxSizerFlagBits { /* for compatibility only, default now, don't use explicitly any more */ #if WXWIN_COMPATIBILITY_2_6 - wxADJUST_MINSIZE = 0, + wxADJUST_MINSIZE = 0, #endif + wxFIXED_MINSIZE = 0x8000, + wxRESERVE_SPACE_EVEN_IF_HIDDEN = 0x0002, + + /* a mask to extract wxSizerFlagBits from combination of flags */ + wxSIZER_FLAG_BITS_MASK = 0x8002 +}; +enum wxStretch +{ wxSTRETCH_NOT = 0x0000, wxSHRINK = 0x1000, wxGROW = 0x2000, wxEXPAND = wxGROW, wxSHAPED = 0x4000, - wxFIXED_MINSIZE = 0x8000, - wxTILE = 0xc000 + wxTILE = wxSHAPED | wxFIXED_MINSIZE, + + /* a mask to extract stretch from the combination of flags */ + wxSTRETCH_MASK = 0x7000 /* sans wxTILE */ }; /* border flags: the values are chosen for backwards compatibility */ diff --git a/include/wx/sizer.h b/include/wx/sizer.h index b97b7c0854..640f7a5681 100644 --- a/include/wx/sizer.h +++ b/include/wx/sizer.h @@ -170,6 +170,13 @@ public: return *this; } + // makes the item ignore window's visibility status + wxSizerFlags& ReserveSpaceEvenIfHidden() + { + m_flags |= wxRESERVE_SPACE_EVEN_IF_HIDDEN; + return *this; + } + // accessors for wxSizer only int GetProportion() const { return m_proportion; } int GetFlags() const { return m_flags; } @@ -332,10 +339,12 @@ public: { return m_kind == Item_Sizer ? m_sizer : NULL; } wxSize GetSpacer() const; - // this function behaves obviously for the windows and spacers but for the + // This function behaves obviously for the windows and spacers but for the // sizers it returns true if any sizer element is shown and only returns - // false if all of them are hidden + // false if all of them are hidden. Also, it always returns true if + // wxRESERVE_SPACE_EVEN_IF_HIDDEN flag was used. bool IsShown() const; + void Show(bool show); void SetUserData(wxObject* userData) diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index cc81970cb5..6d70ae0bc3 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -522,6 +522,9 @@ void wxSizerItem::Show( bool show ) bool wxSizerItem::IsShown() const { + if ( m_flag & wxRESERVE_SPACE_EVEN_IF_HIDDEN ) + return true; + switch ( m_kind ) { case Item_None: -- 2.45.2