X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/20b35a6916b9b54af4bbfe4227393c08cd9a2724..7fa4dc1cfcc55b0fe425a3ebe5e992ff8255481b:/src/common/sizer.cpp diff --git a/src/common/sizer.cpp b/src/common/sizer.cpp index 1d187529ff..c2320a4d5a 100644 --- a/src/common/sizer.cpp +++ b/src/common/sizer.cpp @@ -25,7 +25,11 @@ #include "wx/utils.h" #include "wx/statbox.h" #include "wx/notebook.h" -#include +#include "wx/listimpl.cpp" + +#ifdef __WXMAC__ +# include "wx/mac/uma.h" +#endif //--------------------------------------------------------------------------- @@ -189,13 +193,16 @@ wxSize wxSizerItem::CalcMin() } else { - if ( IsWindow() && (m_flag & wxADJUST_MINSIZE) ) + if ( IsWindow() && !(m_flag & wxFIXED_MINSIZE) ) { - // By user request, keep the minimal size for this item - // in sync with the largest of BestSize and any user supplied - // minimum size hint. Useful in cases where the item is - // changeable -- static text labels, etc. - m_minSize = m_window->GetAdjustedBestSize(); + // Since the size of the window may change during runtime, we + // should use the current minimal size. If there is a MinSize, + // use it, otherwise use the BestSize. + wxSize min = m_window->GetMinSize(); + wxSize best = m_window->GetBestSize(); + if (min.x == -1) min.x = best.x; + if (min.y == -1) min.y = best.y; + m_minSize = min; } ret = m_minSize; @@ -278,7 +285,10 @@ void wxSizerItem::SetDimension( wxPoint pos, wxSize size ) void wxSizerItem::DeleteWindows() { if (m_window) + { m_window->Destroy(); + m_window = NULL; + } if (m_sizer) m_sizer->DeleteWindows(); @@ -641,6 +651,10 @@ wxSize wxSizer::GetMinWindowSize( wxWindow *window ) minSize.y+size.y-client_size.y ); } +// TODO on mac we need a function that determines how much free space this +// min size contains, in order to make sure that we have 20 pixels of free +// space around the controls + // Return a window size that will fit within the screens dimensions wxSize wxSizer::FitSize( wxWindow *window ) { @@ -729,7 +743,7 @@ bool wxSizer::DoSetItemMinSize( wxWindow *window, int width, int height ) if (item->GetWindow() == window) { - item->SetInitSize( width, height ); + item->SetMinSize( width, height ); return true; } node = node->GetNext(); @@ -808,7 +822,7 @@ bool wxSizer::DoSetItemMinSize( size_t index, int width, int height ) else { // ... but the minimal size of spacers and windows in stored in them - item->SetInitSize( width, height ); + item->SetMinSize( width, height ); } return true; @@ -1132,10 +1146,11 @@ wxSize wxFlexGridSizer::CalcMin() m_rowHeights.SetCount(nrows); m_colWidths.SetCount(ncols); - // We have to recalcuate the sizes in case an item has wxADJUST_MINSIZE, has changed - // minimum size since the previous layout, or has been hidden using wxSizer::Show(). - // If all the items in a row/column are hidden, the final dimension of the row/column - // will be -1, indicating that the column itself is hidden. + // We have to recalcuate the sizes in case the item minimum size has + // changed since the previous layout, or the item has been hidden using + // wxSizer::Show(). If all the items in a row/column are hidden, the final + // dimension of the row/column will be -1, indicating that the column + // itself is hidden. for( s = m_rowHeights.GetCount(), i = 0; i < s; ++i ) m_rowHeights[ i ] = -1; for( s = m_colWidths.GetCount(), i = 0; i < s; ++i ) @@ -1548,7 +1563,32 @@ static void GetStaticBoxBorders( wxStaticBox *box, // guess the thickness of a wxStaticBox border #ifdef __WXCOCOA__ box->GetBordersForSizer(borderTop,borderOther); -#else // __WXCOCOA__ +#elif defined(__WXMAC__) + + static int extraTop = -1; // Uninitted + static int other = 5; + + if ( extraTop == -1 ) + { + // The minimal border used for the top. Later on the staticbox' + // font height is added to this. + extraTop = 0; + + if ( UMAGetSystemVersion() >= 0x1030 /*Panther*/ ) + { + // As indicated by the HIG, Panther needs an extra border of 11 + // pixels (otherwise overlapping occurs at the top). The "other" + // border has to be 11. + extraTop = 11; + other = 11; + } + + } + + *borderTop = extraTop + box->GetCharHeight(); + *borderOther = other; + +#else #ifdef __WXGTK__ if ( box->GetLabel().IsEmpty() ) *borderTop = 5; @@ -1592,6 +1632,12 @@ wxSize wxStaticBoxSizer::CalcMin() return ret; } +void wxStaticBoxSizer::ShowItems( bool show ) +{ + m_staticBox->Show( show ); + wxBoxSizer::ShowItems( show ); +} + #endif // wxUSE_STATBOX // ----------------------------------------------------------------------------