merged 2.4 branch into the trunk

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@18040 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-12-04 14:11:26 +00:00
parent 59a944cb63
commit 2b5f62a0b2
1057 changed files with 37805 additions and 24034 deletions

View File

@@ -50,6 +50,7 @@ wxSizerItem::wxSizerItem( int width, int height, int option, int flag, int borde
m_option = option;
m_border = border;
m_flag = flag;
m_show = TRUE; // Cannot be changed
m_userData = userData;
// minimal size is the initial size
@@ -69,6 +70,7 @@ wxSizerItem::wxSizerItem( wxWindow *window, int option, int flag, int border, wx
m_option = option;
m_border = border;
m_flag = flag;
m_show = TRUE;
m_userData = userData;
// minimal size is the initial size
@@ -88,6 +90,7 @@ wxSizerItem::wxSizerItem( wxSizer *sizer, int option, int flag, int border, wxOb
m_option = option;
m_border = border;
m_flag = flag;
m_show = TRUE;
m_userData = userData;
// minimal size is calculated later
@@ -145,14 +148,11 @@ wxSize wxSizerItem::CalcMin()
{
if ( IsWindow() && (m_flag & wxADJUST_MINSIZE) )
{
// check if the best (minimal, in fact) window size hadn't changed
// by chance: this may happen for, e.g. static text if its label
// changed
wxSize size = m_window->GetBestSize();
if ( size.x > m_minSize.x )
m_minSize.x = size.x;
if ( size.y > m_minSize.y )
m_minSize.y = size.y;
// 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();
}
ret = m_minSize;
@@ -361,6 +361,8 @@ bool wxSizer::Remove( wxSizer *sizer )
bool wxSizer::Remove( int pos )
{
if ((size_t)pos >= m_children.GetCount())
return FALSE;
wxNode *node = m_children.Nth( pos );
if (!node) return FALSE;
@@ -528,8 +530,7 @@ void wxSizer::SetDimension( int x, int y, int width, int height )
m_position.y = y;
m_size.x = width;
m_size.y = height;
CalcMin();
RecalcSizes();
Layout();
}
wxSize wxSizer::GetMinSize()
@@ -636,6 +637,90 @@ bool wxSizer::DoSetItemMinSize( int pos, int width, int height )
return TRUE;
}
void wxSizer::Show(wxWindow *window, bool show)
{
wxNode *node = m_children.GetFirst();
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->IsWindow() && item->GetWindow() == window)
{
item->Show(show);
window->Show(show);
return;
}
node = node->Next();
}
}
void wxSizer::Show(wxSizer *sizer, bool show)
{
wxNode *node = m_children.GetFirst();
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->IsSizer() && item->GetSizer() == sizer)
{
item->Show(show);
sizer->ShowItems(show);
return;
}
node = node->Next();
}
}
void wxSizer::ShowItems (bool show)
{
wxNode *node = m_children.GetFirst();
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->IsWindow())
item->GetWindow()->Show (show);
else if (item->IsSizer())
item->GetSizer()->ShowItems (show);
node = node->Next();
}
}
bool wxSizer::IsShown (wxWindow *window)
{
wxNode *node = m_children.GetFirst();
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->IsWindow() && item->GetWindow() == window)
{
return item->IsShown();
}
node = node->Next();
}
return FALSE;
}
bool wxSizer::IsShown (wxSizer *sizer)
{
wxNode *node = m_children.GetFirst();
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->IsSizer() && item->GetSizer() == sizer)
{
return item->IsShown();
}
node = node->Next();
}
return FALSE;
}
//---------------------------------------------------------------------------
// wxGridSizer
//---------------------------------------------------------------------------
@@ -659,7 +744,7 @@ wxGridSizer::wxGridSizer( int cols, int vgap, int hgap )
int wxGridSizer::CalcRowsCols(int& nrows, int& ncols) const
{
int nitems = m_children.GetCount();
if ( nitems)
if ( nitems)
{
if ( m_cols )
{
@@ -978,62 +1063,64 @@ void wxBoxSizer::RecalcSizes()
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
int weight = 1;
if (item->GetOption())
weight = item->GetOption();
wxSize size( item->CalcMin() );
if (m_orient == wxVERTICAL)
if (item->IsShown())
{
wxCoord height = size.y;
int weight = 1;
if (item->GetOption())
weight = item->GetOption();
wxSize size( item->CalcMin() );
if (m_orient == wxVERTICAL)
{
height = (delta * weight) + extra;
extra = 0; // only the first item will get the remainder as extra size
wxCoord height = size.y;
if (item->GetOption())
{
height = (delta * weight) + extra;
extra = 0; // only the first item will get the remainder as extra size
}
wxPoint child_pos( pt );
wxSize child_size( wxSize( size.x, height) );
if (item->GetFlag() & (wxEXPAND | wxSHAPED))
child_size.x = m_size.x;
else if (item->GetFlag() & wxALIGN_RIGHT)
child_pos.x += m_size.x - size.x;
else if (item->GetFlag() & (wxCENTER | wxALIGN_CENTER_HORIZONTAL))
// XXX wxCENTER is added for backward compatibility;
// wxALIGN_CENTER should be used in new code
child_pos.x += (m_size.x - size.x) / 2;
item->SetDimension( child_pos, child_size );
pt.y += height;
}
wxPoint child_pos( pt );
wxSize child_size( wxSize( size.x, height) );
if (item->GetFlag() & (wxEXPAND | wxSHAPED))
child_size.x = m_size.x;
else if (item->GetFlag() & wxALIGN_RIGHT)
child_pos.x += m_size.x - size.x;
else if (item->GetFlag() & (wxCENTER | wxALIGN_CENTER_HORIZONTAL))
// XXX wxCENTER is added for backward compatibility;
// wxALIGN_CENTER should be used in new code
child_pos.x += (m_size.x - size.x) / 2;
item->SetDimension( child_pos, child_size );
pt.y += height;
}
else
{
wxCoord width = size.x;
if (item->GetOption())
else
{
width = (delta * weight) + extra;
extra = 0; // only the first item will get the remainder as extra size
wxCoord width = size.x;
if (item->GetOption())
{
width = (delta * weight) + extra;
extra = 0; // only the first item will get the remainder as extra size
}
wxPoint child_pos( pt );
wxSize child_size( wxSize(width, size.y) );
if (item->GetFlag() & (wxEXPAND | wxSHAPED))
child_size.y = m_size.y;
else if (item->GetFlag() & wxALIGN_BOTTOM)
child_pos.y += m_size.y - size.y;
else if (item->GetFlag() & (wxCENTER | wxALIGN_CENTER_VERTICAL))
// XXX wxCENTER is added for backward compatibility;
// wxALIGN_CENTER should be used in new code
child_pos.y += (m_size.y - size.y) / 2;
item->SetDimension( child_pos, child_size );
pt.x += width;
}
wxPoint child_pos( pt );
wxSize child_size( wxSize(width, size.y) );
if (item->GetFlag() & (wxEXPAND | wxSHAPED))
child_size.y = m_size.y;
else if (item->GetFlag() & wxALIGN_BOTTOM)
child_pos.y += m_size.y - size.y;
else if (item->GetFlag() & (wxCENTER | wxALIGN_CENTER_VERTICAL))
// XXX wxCENTER is added for backward compatibility;
// wxALIGN_CENTER should be used in new code
child_pos.y += (m_size.y - size.y) / 2;
item->SetDimension( child_pos, child_size );
pt.x += width;
}
node = node->Next();
@@ -1057,7 +1144,7 @@ wxSize wxBoxSizer::CalcMin()
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
if (item->GetOption() != 0)
if (item->IsShown() && item->GetOption() != 0)
{
int stretch = item->GetOption();
wxSize size( item->CalcMin() );
@@ -1077,43 +1164,44 @@ wxSize wxBoxSizer::CalcMin()
while (node)
{
wxSizerItem *item = (wxSizerItem*) node->Data();
m_stretchable += item->GetOption();
wxSize size( item->CalcMin() );
if (item->GetOption() != 0)
if (item->IsShown())
{
m_stretchable += item->GetOption();
wxSize size( item->CalcMin() );
if (item->GetOption() != 0)
{
if (m_orient == wxHORIZONTAL)
size.x = stretchSize * item->GetOption();
else
size.y = stretchSize * item->GetOption();
}
if (m_orient == wxHORIZONTAL)
size.x = stretchSize * item->GetOption();
else
size.y = stretchSize * item->GetOption();
}
if (m_orient == wxHORIZONTAL)
{
m_minWidth += size.x;
m_minHeight = wxMax( m_minHeight, size.y );
}
else
{
m_minHeight += size.y;
m_minWidth = wxMax( m_minWidth, size.x );
}
if (item->GetOption() == 0)
{
if (m_orient == wxVERTICAL)
{
m_fixedHeight += size.y;
m_fixedWidth = wxMax( m_fixedWidth, size.x );
m_minWidth += size.x;
m_minHeight = wxMax( m_minHeight, size.y );
}
else
{
m_fixedWidth += size.x;
m_fixedHeight = wxMax( m_fixedHeight, size.y );
m_minHeight += size.y;
m_minWidth = wxMax( m_minWidth, size.x );
}
if (item->GetOption() == 0)
{
if (m_orient == wxVERTICAL)
{
m_fixedHeight += size.y;
m_fixedWidth = wxMax( m_fixedWidth, size.x );
}
else
{
m_fixedWidth += size.x;
m_fixedHeight = wxMax( m_fixedHeight, size.y );
}
}
}
node = node->Next();
}